## Checklist for adding a new Lambda ### 1. Create the Lambda scaffold - Copy the template: cp -r lambda/_template lambda/ - Update `variables.tf` if required - Ensure the Terraform module accepts: - `lambda_name` - `stage` - `image_uri` --- ### 2. Add infrastructure prerequisites (shared stack) - Add a new ECR repository in: infrastructure/terraform/shared/main.tf - Apply the shared stack (or let CI apply it on `prod`) - Verify the ECR repository exists in AWS Note: No Terraform outputs are required for the ECR repo. The CI pipeline resolves the repository URL dynamically at build time. --- ### 3. Add Docker build configuration - Create a `Dockerfile` for the Lambda - Verify the Dockerfile path and build context - Add a new image build job in `deploy_terraform.yml` using `_build_image.yml` --- ### 4. Wire the Lambda deploy job (CI) - Add a deploy job using `_deploy_lambda.yml` - Pass the following inputs: - `lambda_name` - `lambda_path` - `stage` - `image_uri` (constructed as `repo@sha256:digest`) - Ensure the deploy job depends on the image build job --- ### 5. Deploy - Push changes to GitHub - CI will: 1. Build and push the Docker image 2. Resolve the image digest 3. Deploy the Lambda using the immutable `image_uri` --- ## Notes - Terraform remote state is not used for image wiring - Image tags are not used; deployments are digest-based - By default, the template wires SQS → Lambda To change this, update the Terraform in `lambda/` (e.g. EventBridge, API Gateway, direct invoke) --- ## Rule of thumb CI decides what image to deploy. Terraform only deploys it.