save exisiting work

This commit is contained in:
Jun-te Kim 2025-07-17 20:18:46 +00:00
parent 0be7ef6c89
commit e5ba53e787
6 changed files with 80 additions and 0 deletions

View 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"]

View 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)
}

View 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"
}

View 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
}