Introduction
LocalStack runs a functional emulator of AWS on a developer laptop, a Docker Compose file, or a Kubernetes cluster so you can write, test, and run integration tests for cloud-native apps without touching a real AWS account. It is the default choice for anyone practicing TDD against AWS APIs.
What LocalStack Does
- Emulates ~80 AWS services including S3, Lambda, DynamoDB, SQS/SNS, Kinesis, Step Functions
- Presents a unified endpoint on
:4566that speaks every AWS service protocol - Persists state to disk so containers can be restarted without losing buckets/tables
- Supports Lambda runtimes via Docker (Python, Node, Go, Java, .NET, Ruby)
- Integrates with Terraform, CDK, Serverless Framework, Pulumi, and awscli
Architecture Overview
LocalStack is a Python (moto-derived) service that terminates AWS API requests, dispatches them to per-service handlers, and returns AWS-compatible XML/JSON. Lambda invocations spawn transient Docker containers that mount the user's code and execute it. The Pro edition adds EKS, ECS-on-Fargate, IAM enforcement, and Cloud Pods (state snapshots). Everything runs inside one localstack/localstack image with an HTTP entry point on 4566.
Self-Hosting & Configuration
- Run with
docker compose up; override services viaSERVICES=s3,sqs,lambda - Point SDKs via
AWS_ENDPOINT_URL=http://localhost:4566(supported by boto3 ≥ 1.28) - Persistence:
PERSISTENCE=1writes state to/var/lib/localstack - Lambda:
LAMBDA_EXECUTOR=docker-reusefor faster cold-starts in CI - Pro features (IAM, EKS, RDS) require
LOCALSTACK_AUTH_TOKEN
Key Features
- Fastest feedback loop for AWS development — no round trip to us-east-1
- CI-friendly: spin up, run tests, tear down in under 10 seconds
- Cloud Pods: snapshot and share a fully-populated cloud environment
- Chaos engineering: inject latency and failures to test resilience
- Active OSS community with 50k+ GitHub stars
Comparison with Similar Tools
- Moto — Python in-process mock; lighter but only works inside test runners
- AWS SAM local — only emulates Lambda/API GW; not a full AWS fabric
- LocalStack Pro — commercial add-on; adds advanced services and IAM enforcement
- MinIO — S3-only, very fast; combine with LocalStack for production-close storage tests
- DynamoDB Local — single-service official emulator; narrower scope
FAQ
Q: Does LocalStack cost money for CI? A: Community edition is free. Some services (EKS, RDS proxy, IAM soft enforcement) need Pro.
Q: Can I run real Lambda code? A: Yes. Lambda code runs inside Docker images matching the official runtime containers.
Q: Does Terraform work against LocalStack?
A: Yes. Override the endpoints block for every AWS provider service you use.
Q: How is persistence handled?
A: Set PERSISTENCE=1 and mount /var/lib/localstack as a volume; state survives restarts.