Skip to content

A simple example of hot-reloading lambda functions with LocalStack and local Terraform deploys

Notifications You must be signed in to change notification settings

Unit2795/LocalStack-Terraform-AWS-Lambda

Repository files navigation

LocalStack & Terraform REST API

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:

  1. Set up LocalStack Pro

  2. Deploy resources to LocalStack using one of the following IaC providers:

    1. Terraform HCL .tf
    2. Terraform CDK (CDKTF) .ts
  3. Query your local REST API

Key Files/Directories

  • 📁 /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' } and 200 http status code
  • 📄.env.example
    • File that contains LocalStack Pro key, copy this to a .env file
  • 📄main.tf
    • Primary Terraform HCL file used to create and manage AWS resources

Why do I need to have LocalStack Pro?

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!