This is a boilerplate to help you initiate AWS Lambda project using Typescript, in this boilerplate there are terraform code to provision the stacks and the initial Typescript source code in the sources directory
This is a boilerplate to help you initiate AWS Lambda project using Typescript, in this boilerplate there are terraform code to provision the stacks and the initial Typescript source code in the sources directory
Features
Terraform code to provision the AWS Lambda project
Typescript source code in the sources directory
Automatically load AWS Secrets Manager (parameter store) as environment variables
Automatically load DynamoDB (table name) as environment variables
Automatically create models for DynamoDB tables with the ability to read, write, delete, and scan
Decorator example to log the execution time of the method
Datadog example integration to stream the metrics of statistic decorator to Datadog
Lambda layer to store the dependencies of the project
Lambda scheduler to schedule the function invocation
While doing a terraform apply command, theese are the things that will be created:
AWS Lambda Function, in the main.tf there's a logic on creating AWS Lambda function based on files with format *.function.ts under sources/src/functions directory, so the number of AWS Lambda function created is based on *.function.ts files
AWS System Manager Parameter Store, in the main.tf there's a logic on creating AWS Parameter Store with prefix set on parameter_store_path under variables.tf based on:
parameter_store_list attributes under variables.tf file
dynamodb_table_list attributes under variables.tf file which will create a Parameter Store to store the table names of DynamoDB with format dynamodb-table-{table_name}
service_version attributes under variables.tf file which will create a Parameter Store to store the version of the service
Another context related to the Typescript source code:
sources/src/helpers is the collection of functional helpers such as populateEnvironmentVariables() you can freely add another functional helpers under this directory
sources/src/libraries is the collection of class helpers such as DatadogLibrary which contains all Datadog functionality such as publishMetrics and publishEvents, or another example DynamoDBLibrary which contains putItem and getItem
sources/src/decorators is the collection of Typescript decorators, the initial example is @statistic decorator which have the functionality to log the execution duration for the method that uses the decorators, the example also include the additional process to stream the statistic metrics into Datadog
sources/src/index.ts is a bootstraper file which contains default exports.handlers function, which is the default function that will be called by AWS Lambda Function, this file contains logic to create the sources/src/functions/*.function.ts instance and create object then call the handler method
sources/src/models is the collection of Typescript models, the initial example is Booking which is the model for DynamoDB table booking which automatically created by terraform code