This repository contains Terraform-based sample projects that can be deployed on your local machine using LocalStack.
Each example in the repository is prefixed with the AWS service being used. For example, the apigateway-dynamodb directory contains a sample showing API Gateway and DynamoDB resources provisioned with Terraform. Refer to each sample directory for detailed instructions.
- Docker
localstackCLIawslocalCLI- Terraform
makeandjq
All samples require a valid LocalStack for AWS license. Your license provides a LOCALSTACK_AUTH_TOKEN to activate LocalStack.
Set it before running any sample:
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>Alternatively, use the LocalStack CLI to persist the token:
localstack auth set-token <your-auth-token>You can find your auth token in the LocalStack Web Application.
| Sample Name | Description |
|---|---|
| ACM + Route53 | Generate an ACM certificate and validate it with Route53 records. |
| API Gateway + DynamoDB | Provision a REST API that works with DynamoDB. |
| API Gateway HTTP Proxy Authorizer | Configure API Gateway REST methods with Lambda authorizer and proxy integrations. |
| API Gateway + Kinesis | Integrate API Gateway REST endpoints with Kinesis streams. |
| API Gateway + Kinesis + Lambda | Connect API Gateway to Kinesis with Lambda producer and consumer functions. |
| API Gateway Lambda CORS | Configure API Gateway Lambda integration with CORS support. |
| API Gateway REST CORS | Configure REST API MOCK integrations and CORS responses. |
| API Gateway SNS Deploy | Publish API Gateway requests to SNS topics. |
| API Gateway Stage Cluster | Deploy API Gateway stages and stage-specific routes/integrations. |
| API Gateway Stage Variables | Use stage variables with API Gateway REST APIs. |
| API Gateway + Step Functions | Integrate API Gateway REST endpoints with Step Functions. |
| API Gateway V2 HTTP + Kinesis | Integrate HTTP APIs (v2) with Kinesis streams. |
| API Gateway V2 Lambda Proxy | Create an HTTP API (v2) with Lambda proxy integration. |
| API Gateway V2 Lambda Binary Proxy | Handle binary payloads using API Gateway v2 Lambda proxy integrations. |
| API Gateway V2 Lambda Proxy Integration | API Gateway v2 Lambda proxy integration flow. |
| API Gateway V2 Lambda Authorizer 1.0 | HTTP API Lambda request authorizer with payload format version 1.0. |
| API Gateway V2 Lambda Authorizer 2.0 | HTTP API Lambda request authorizer with payload format version 2.0. |
| API Gateway V2 + Step Functions | Integrate HTTP APIs (v2) with Step Functions. |
| API Gateway V2 WebSocket + HTTP | WebSocket API integration with HTTP backends. |
| API Gateway V2 WebSocket HTTP Proxy | WebSocket API integration using HTTP proxy mode. |
| API Gateway V2 WebSocket + Kinesis | WebSocket API integration with Kinesis streams. |
| API Gateway V2 WebSocket Authorizer | WebSocket API with Lambda request authorizer. |
| API Gateway V2 WebSocket Sample | End-to-end WebSocket API sample with connect/disconnect handlers and auth. |
| API Gateway V2 WebSocket + SNS | Publish WebSocket messages through SNS integrations. |
| API Gateway V2 WebSocket + SQS | Publish WebSocket messages through SQS integrations. |
| API Gateway V2 WebSocket Subprotocol | WebSocket API handling custom sub-protocols. |
| Cognito Group Example | Create Cognito user pools and user groups. |
| Demo Deploy | Modular Terraform deployment for API Gateway, S3, SQS, DynamoDB, and authorizers. |
| Lambda + Kinesis + Firehose + Elasticsearch | Build a data pipeline with Lambda, Kinesis, Firehose, and Elasticsearch/OpenSearch resources. |
| Managed Streaming for Kafka Cluster | Provision a Kafka cluster and supporting resources with Terraform. |
| S3 + SQS Notifications | Configure S3 event notifications to SQS. |
| S3 Static Website | Deploy a static website on S3. |
| WebSocket Deploy | Basic WebSocket API deployment with Lambda backend. |
Archived and non-functional samples are kept in sample-archive/.
To check out only one sample directory:
mkdir localstack-terraform-samples && cd localstack-terraform-samples
git init
git remote add origin -f git@github.com:localstack-samples/localstack-terraform-samples.git
git config core.sparseCheckout true
echo <LOCALSTACK_SAMPLE_DIRECTORY_NAME> >> .git/info/sparse-checkout
git pull origin masterThe commands above use sparse checkout to pull only the sample you need.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.