AWS Lambda Framework
A framework for simplifying writing AWS Lambda functions in typescript featuring IoC with services for input validation, sending slack notifications, connecting to databases, and using AWS services.
For release notes, see the CHANGELOG
This project is still in the early stages, any feedback is much appreciated. Please let me know of any services or features you feel could improve this framework!
Motivation
When developing microservice architectures on aws, a lot of common functionality has to be implemented into each Lambda function. This framework has been developed to provide that scaffolding as well streamline error handling and responses, such that anyone using Lambda functions through an API can always expect the same output.
Installation
npm i aws-lambda-framework --save
Usage
To utilize the framework your Lambda functions should extend the BaseLambda abstract class. This class provides scaffolding for your Lambda functions, ensuring that any results or errors are properly formatted for APIGateway and sent back to the caller. Errors are automatically logged and optionally send to a Slack channel of your choice. New Lambda functions must implement an invoke
function, which ensures that the previously mentions points occur. This function also returns a LambdaResult to standardize the results for the end user, containing a userMessage and optionally a data object.
Basic example
// class TestLambda.ts // interface Country.ts
Kitchensink Example
// KitchensinkLambda.ts // Kitchensink.ts // KitchensinkRepository.ts // UpdateKitchensinkRequest.ts // validatePermissions.ts // validateRequest.ts
Services
The framework provides easy access to some of the tools that are often needed when writing Lambda functions. These are injected as singletons into the Container the first time they are called.
Validator
Mysql
Postgres
SlackNotifier
AWS Services
- APIGateway
- Aurora
- Cloudwatch
- DynamoDB
- DynamoDC (Document Client)
- Kinesis
- Lambda
- RDS
- Redshift
- S3
- SES
- SSM