❗ Contributors: See Development |
---|
The boilerplate serves as the starting point for rolling out a new Lambda. The boilerplate includes
- Terraform
- Terraform CDK in TypeScript
- Example Lambda Handlers and common interfaces, utilities, etc.
The following patterns are shown in the boilerplate in Terraform, Terraform CDK in TypeScript, and TypeScript Lambda handlers.
- SNS consumer
- SQS consumer
- CRON job
- Utilizing ElastiCache in a Lambda
- API Gateway integration
This assumes you have the pre-requisites already configured, an AWS Profile configured, and a KMS Key admin role.
For more information on how to configure an AWS Profile on your workstation, please see Adding a profile by editing the shared AWS credentials file
Compile and build the Typescript Lambda code. Navigate to the root of the repo to run the following commands.
- Install Lambda packages:
make bootstrap-lambda
- Build the Lambda:
make build
Once you have completed the steps in Getting Started, you will need to configure
the terraform
dependencies.
-
Navigate to
aws-lambdas/terraform
:cd aws-lambdas/terraform
-
Set your AWS Profile environment variable:
export AWS_PROFILE=<profile_name>
-
Configure your local
tfvars
file.example.tfvars
profile = "<profile_name>" kms_key_admin_arns = [ "arn:aws:iam::<account_id>:role/<kms_admin_role_name>" ]
This file should include:
- The
profile
variable override - The
kms_key_admin_arns
variable override. This is for additional IAM roles to map to the KMS key policy for administering the KMS key used for SSE.
- The
-
Initialize:
terraform init -var-file=example.tfvars
-
Plan:
terraform plan -var-file=example.tfvars
-
If the plan looks good, run apply:
terraform apply -var-file=example.tfvars
In the Lambda module's README, there is a usage example you can reference to create additional resources in the terraform root's configuration.
Since the code contained in this repo is only intended to serve as a boilerplate, the local backend is being used.
- The
local
backend keeps the state local. These files are ignored in the repo's .gitignore. DO NOT remove the state files from the .gitignore since the state file may contain sensitive values.
For more information on backends, see the Terraform docs list of available backends.
Quality Control MUST be configured prior to making any commits.
Preferred workstation setup can be found in Confluence.
This repo leverages Pre-Commit to ensure code quality and standardization.
To get started, install pre-commit:
pip install pre-commit
Once pre-commit is installed, run pre-commit install
from the root of this repo. This executes
prior to commits to the repo.
This project is authored by below people
- SourceFuse