Typescript Lambda Boilerplate¶
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
Pre-Requisites¶
Getting Started: Build out Lambda¶
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:
- Build the Lambda:
Terraform to deploy your Lambda¶
Once you have completed the steps in Getting Started, you will need to configure
the terraform
dependencies.
This does not have a backend configured. See Backend configuration for more information.
- Navigate to
aws-lambdas/terraform
: - Set your AWS Profile environment variable:
-
Configure your local
tfvars
file.
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:
- Plan:
- If the plan looks good, run apply:
Creating additional Lambdas¶
In the Lambda module's README, there is a usage example you can reference to create additional resources in the terraform root's configuration.
Backend 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.
Development¶
Quality Control MUST be configured prior to making any commits.
Preferred workstation setup can be found in Confluence.
Quality Control¶
This repo leverages Pre-Commit to ensure code quality and standardization.
To get started, 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.
Authors¶
This project is authored by below people
- SourceFuse