Skip to content

Feat/serverless backend lambda - #2

Merged
MarcoManduca merged 8 commits into
mainfrom
feat/serverless-backend-lambda
Jul 8, 2026
Merged

Feat/serverless backend lambda#2
MarcoManduca merged 8 commits into
mainfrom
feat/serverless-backend-lambda

Conversation

@MarcoManduca

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 8, 2026 14:09
@MarcoManduca
MarcoManduca merged commit 79cffdc into main Jul 8, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the backend runtime from ECS Fargate + ALB to a container-image AWS Lambda exposed via a Lambda Function URL and fronted by the existing CloudFront distribution, while also introducing a DynamoDB-backed contact-form rate limiter to make rate limiting consistent across Lambda cold starts.

Changes:

  • Replace the ECS/ALB backend stack with a Lambda container image + Function URL, and route /api/* to it via CloudFront OAC (SigV4).
  • Add a new DynamoDB TTL table for rate limiting and switch the backend limiter implementation to DynamoDB.
  • Update Terraform variables/outputs plus deployment/local-dev scripts and documentation to match the new architecture.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Updates top-level architecture diagram and hosting stack description to Lambda.
infra/terraform/variables.tf Replaces ECS sizing vars with Lambda memory/timeout vars.
infra/terraform/terraform.tfvars.example Updates example backend sizing inputs for Lambda.
infra/terraform/providers.tf Removes the random provider requirement (no longer used).
infra/terraform/outputs.tf Replaces ECS/ALB outputs with the backend Lambda function name output.
infra/terraform/modules/database/outputs.tf Exposes the new ratelimit table name/ARN via module outputs.
infra/terraform/modules/database/main.tf Adds the DynamoDB ratelimit table with TTL enabled.
infra/terraform/modules/cdn/variables.tf Replaces ALB origin variables with Lambda Function URL host + function name inputs.
infra/terraform/modules/cdn/main.tf Switches /api/* origin to Lambda Function URL via OAC and adds invoke permission.
infra/terraform/modules/backend/variables.tf Replaces ECS-related vars with Lambda-oriented configuration (arch/memory/timeout).
infra/terraform/modules/backend/outputs.tf Exposes Lambda function name and Function URL host instead of ECS/ALB details.
infra/terraform/modules/backend/main.tf Implements Lambda function + Function URL + log group, removing ECS/ALB runtime.
infra/terraform/modules/backend/iam.tf Replaces ECS task/execution roles with a single Lambda execution role + policy.
infra/terraform/modules/backend/ecs.tf Removes ECS cluster/task/service resources (deleted).
infra/terraform/modules/backend/alb.tf Removes ALB/cert/DNS/origin-secret resources (deleted).
infra/terraform/main.tf Rewires modules for Lambda backend + passes new env var for rate limit table.
infra/scripts/deploy-backend.sh Updates deploy script to aws lambda update-function-code and arm64 builds.
infra/scripts/create-local-tables.sh Adds creation of the local ratelimit DynamoDB table.
infra/README.md Updates infra docs/runbook/diagrams and provisioning steps for Lambda + Function URL.
docker-compose.yml Adds RATELIMIT_TABLE_NAME env var for local services.
backend/tests/unit/utils/test_rate_limit.py Replaces in-memory limiter tests with moto-backed DynamoDB limiter tests.
backend/tests/conftest.py Adds ratelimit table env + test table creation.
backend/src/utils/rate_limit.py Replaces in-memory limiter with DynamoDB-backed fixed-window limiter + dependency.
backend/src/config.py Adds ratelimit_table_name setting/env mapping.
backend/README.md Updates backend documentation for Lambda runtime + DynamoDB-backed rate limiting.
backend/Dockerfile Adds AWS Lambda Web Adapter extension and readiness configuration.
backend/.env.example Adds RATELIMIT_TABLE_NAME and updates rate-limit docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to 61
resource "aws_lambda_function_url" "backend" {
function_name = aws_lambda_function.backend.function_name
authorization_type = "AWS_IAM"
}
Comment on lines +45 to 49
echo "Updating Lambda function ${FUNCTION_NAME} to image ${GIT_SHA}..."
aws lambda update-function-code \
--function-name "${FUNCTION_NAME}" \
--image-uri "${ECR_REPOSITORY_URL}:${GIT_SHA}" \
--region "${AWS_REGION}" > /dev/null
@MarcoManduca
MarcoManduca deleted the feat/serverless-backend-lambda branch July 8, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants