This is an example that uses Terraform and LocalStack to spin up a local hot-reloading Node.js AWS Lambda and API Gateway development environment. The features used in this guide require you to have LocalStack Pro. There is a trial membership available. Develop rapidly for the cloud without the associated costs, slow feedback, and risk of actual deployments. LocalStack also works with Pulumi, AWS CloudFormation/CDK, SAM, and more.
In this guide we will:
-
Deploy resources to LocalStack using one of the following IaC providers:
- Terraform HCL
.tf
- Terraform CDK (CDKTF)
.ts
- Terraform HCL
- 📁 /cdktf
- Terraform CDK code used to create and manage AWS resources
- 📁 /docs
- Markdown documentation about the project
- 📁 /lambda
- Very simple lambda function that returns a JSON object
{ message: 'Hello World' }
and200
http status code
- Very simple lambda function that returns a JSON object
- 📄.env.example
- File that contains LocalStack Pro key, copy this to a
.env
file
- File that contains LocalStack Pro key, copy this to a
- 📄main.tf
- Primary Terraform HCL file used to create and manage AWS resources
Some functionality like UpdateIntegration for API Gateway is not currently available for the community edition of LocalStack. It's possible to force the recreation of the API Gateway integration and get around this, but Pro includes a lot of other handy features, such as the Resource Browser which is a web interface for browsing your LocalStack AWS resources.
If this example was helpful to you or you have questions, drop me a line at [email protected]. Contributions are welcome!