mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
save exisiting work
This commit is contained in:
parent
0be7ef6c89
commit
e5ba53e787
6 changed files with 80 additions and 0 deletions
25
deployment/lambda/extractor_and_loader/docker/Dockerfile
Normal file
25
deployment/lambda/extractor_and_loader/docker/Dockerfile
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
FROM public.ecr.aws/lambda/python:3.12
|
||||
|
||||
# Install Poetry (you could pin a version if you like)
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
|
||||
# Add Poetry to PATH
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/task
|
||||
|
||||
# Copy Poetry files first to leverage Docker layer caching
|
||||
COPY pyproject.toml poetry.lock README.md ./
|
||||
COPY etl/ etl/
|
||||
|
||||
|
||||
# Install dependencies into /var/task
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --only main --no-interaction --no-ansi
|
||||
|
||||
# Copy app code
|
||||
COPY deployment/extractor_and_loader/app.py ./
|
||||
|
||||
# Set Lambda handler
|
||||
CMD ["app.handler"]
|
||||
30
deployment/lambda/extractor_and_loader/docker/app.py
Normal file
30
deployment/lambda/extractor_and_loader/docker/app.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""
|
||||
A quick example of lambda working a function in python
|
||||
"""
|
||||
from etl.read_stuff_from_s3_example import print_hello_from_etl_module
|
||||
|
||||
def handler(event, context):
|
||||
print("Outside try statment")
|
||||
print_hello_from_etl_module()
|
||||
try:
|
||||
print("show me something.. anything...")
|
||||
s3_uri = event.get("file_location")
|
||||
if not s3_uri:
|
||||
print("failed to get s3_uri")
|
||||
return {
|
||||
"statusCode": 400,
|
||||
"body": "Missing 'file_location' in event"
|
||||
}
|
||||
print(f"s3 uri is {s3_uri}")
|
||||
|
||||
return {
|
||||
"statusCode": 200,
|
||||
"body": f"s3 uri {s3_uri}"
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
return {
|
||||
"statusCode": 500,
|
||||
"body": str(e)
|
||||
}
|
||||
0
deployment/lambda/extractor_and_loader/docker/main.tf
Normal file
0
deployment/lambda/extractor_and_loader/docker/main.tf
Normal file
0
deployment/lambda/extractor_and_loader/main.tf
Normal file
0
deployment/lambda/extractor_and_loader/main.tf
Normal file
16
deployment/lambda/extractor_and_loader/provider.tf
Normal file
16
deployment/lambda/extractor_and_loader/provider.tf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "~> 6.3.0"
|
||||
}
|
||||
}
|
||||
backend "s3" {
|
||||
bucket = "survey-extractor-tf-state"
|
||||
region = "eu-west-2"
|
||||
profile = "domna.dev" # /home/vscode/aws/credentials
|
||||
key = "env:/dev/extractor_and_loader_lambda.tfstate"
|
||||
}
|
||||
|
||||
required_version = ">= 1.2.0"
|
||||
}
|
||||
9
deployment/lambda/lambda_shared/output.tf
Normal file
9
deployment/lambda/lambda_shared/output.tf
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
output "lambda_exec_role_arn" {
|
||||
description = "The ARN of the IAM role used by the Lambda functions"
|
||||
value = aws_iam_role.lambda_exec_role.arn
|
||||
}
|
||||
|
||||
output "lambda_exec_role_name" {
|
||||
description = "The ARN of the IAM role used by the Lambda functions"
|
||||
value = aws_iam_role.lambda_exec_role.name
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue