You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Develop rapidly for the cloud without the associated costs, slow feedback, and risk of actual deployments using LocalStack!
4
-
5
-
This is a guide on how to set up [Terraform](https://developer.hashicorp.com/terraform) and [LocalStack](https://localstack.cloud/) for local, [hot-reloading](https://docs.localstack.cloud/user-guide/tools/lambda-tools/hot-reloading/) Node.js AWS Lambda and API Gateway development. You'll be able to query your REST API entirely locally. The features used in this guide require you to have [LocalStack Pro](https://localstack.cloud/pricing/). There is a trial membership available.
3
+
This is an example that uses [Terraform](https://developer.hashicorp.com/terraform) and [LocalStack](https://localstack.cloud/) to spin up a local [hot-reloading](https://docs.localstack.cloud/user-guide/tools/lambda-tools/hot-reloading/) Node.js [AWS Lambda](https://aws.amazon.com/lambda/) and [API Gateway](https://aws.amazon.com/api-gateway/) development environment. The features used in this guide require you to have [LocalStack Pro](https://localstack.cloud/pricing/). 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.
6
4
7
5
**In this guide we will:**
8
6
@@ -14,11 +12,25 @@ This is a guide on how to set up [Terraform](https://developer.hashicorp.com/ter
14
12
15
13
3.[Query your local REST API](./docs/query-your-api.md)
16
14
17
-
## Why do I need to have LocalStack Pro?
18
15
19
-
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](https://docs.localstack.cloud/user-guide/web-application/resource-browser/) which is a web interface for browsing your LocalStack AWS resources.
20
16
21
-
# Final Questions
22
-
1. What sort of workflows is this setup good for?
23
-
2. What are some of the limitations of this setup?
24
-
3. Is it better to run the lambda manually or through LocalStack?
17
+
## Key Files/Directories
18
+
19
+
- 📁 /cdktf
20
+
- Terraform CDK code used to create and manage AWS resources
21
+
- 📁 /docs
22
+
- Markdown documentation about the project
23
+
- 📁 /lambda
24
+
- Very simple lambda function that returns a JSON object `{ message: 'Hello World' }` and `200` http status code
25
+
- 📄.env.example
26
+
- File that contains LocalStack Pro key, copy this to a `.env` file
27
+
- 📄main.tf
28
+
- Primary Terraform HCL file used to create and manage AWS resources
29
+
30
+
31
+
32
+
33
+
34
+
## Why do I need to have LocalStack Pro?
35
+
36
+
Some functionality like [UpdateIntegration](https://docs.localstack.cloud/references/coverage/coverage_apigatewayv2/#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](https://docs.localstack.cloud/user-guide/web-application/resource-browser/) which is a web interface for browsing your LocalStack AWS resources.
1. Localstack runs as a Docker container, so we need to [install Docker](https://docs.docker.com/engine/install/) first. Here's a handy GUI client for managing Docker containers, images, and volumes: [(Docker Desktop)](https://www.docker.com/products/docker-desktop).
15
15
3. Install Python and pip
16
16
1. Localstack is installed using Python's package manager, pip. You can download Python from [here](https://www.python.org/downloads/). Pip is included in Python 3.4 and above. But just in case here is pip (https://pypi.org/project/pip/)
5.[Generate a LocalStack API key](https://app.localstack.cloud/account/apikeys)
20
-
6. Copy `.env.example`to`.env` and replace the `LOCALSTACK_API_KEY` value with the key you generated in the LocalStack web interface.
20
+
6. Copy `.env.example`file to a new file named`.env` and replace the `LOCALSTACK_API_KEY` value with the key you generated in the LocalStack web interface.
21
21
7. Install root project dependencies with PNPM
22
22
1. Run `pnpm install` in the project root
23
23
2. This installs the dotenv-cli which we use to read your LocalStack API token from the .env file. This is used to ensure you download and activate LocalStack Pro.
24
24
8. Start the LocalStack Pro Docker container
25
25
1. Run `pnpm run start:localstack` in the project root
26
-
2. This convenience function reads you LocalStack API token and passes it to the LocalStack CLI command `localstack start -d`
26
+
2. This convenience function reads your LocalStack API token and passes it to the LocalStack CLI command `localstack start -d`
27
27
1. The `-d` flag starts LocalStack detached, so you can close your terminal without stopping the Docker container.
28
28
9. You are now ready to configure your IaC provider, return to the project root [README](../README.md) and select your desired IaC provider.
1. Assemble an HTTP request using the API Gateway ID you noted earlier in the IAC setup step ([Terraform HCL](./iac/terraform-hcl.md) OR [Terraform CDK](./iac/terraform-cdk.md))
0 commit comments