Today I want to show you three starter projects for AWS Lambda using CloudFormation and SAM – Serverless Application Model. I always like if I have some boilerplate code and can get started quickly without copying code or project structures from an existing (and mature) project. Therefore I thought it’s good to have them in one repository. You can find them on GitHub. The projects can be used for NodeJS and Java. Also one project contains both: usage of Java and NodeJS Lambdas in one CloudFormation template.
Note: All projects contain a
deploy.sh file which you can run. Each deploy file is using the AWS CLI to package and deploy the CloudFormation template using
aws cloudformation package and
aws cloudformation deploy, so you first have to add an existing S3 bucket (where you have access to!) to
NodeJS Starter Project: Spins up a simple NodeJS Lambda function which is available under the Api path
NodeJS and Java Starter Project: Spins up two simple AWS Lambda functions: one for NodeJS and one for Java. The neat point is here that it’s possible to declare both AWS Lambda functions for NodeJS and Java in one CloudFormation template. You just have to use different values for
CodeUri. In the background, the AWS CLI packages and uploads both artifacts to S3. The functions are available under the Api path
Example code how to use NodeJS and Java in one project:
# Declare other stuff...