# LocalStack — AWS Cloud Service Emulator for Local Development & CI > Run S3, Lambda, DynamoDB, SQS, SNS, IAM, and 80+ other AWS services on your laptop or CI runner in a single Docker container. ## Install Save as a script file and run: # LocalStack — AWS Cloud Service Emulator for Local Development & CI ## Quick Use ```bash # Start LocalStack in Docker docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack # Or via the CLI wrapper pip install localstack localstack start -d # Point awscli at it aws --endpoint-url=http://localhost:4566 s3 mb s3://my-bucket aws --endpoint-url=http://localhost:4566 s3 cp README.md s3://my-bucket/ # In Terraform: terraform provider aws_endpoints { s3 = "http://localhost:4566" ... } ``` ## 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 `:4566` that 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 via `SERVICES=s3,sqs,lambda` - Point SDKs via `AWS_ENDPOINT_URL=http://localhost:4566` (supported by boto3 ≥ 1.28) - Persistence: `PERSISTENCE=1` writes state to `/var/lib/localstack` - Lambda: `LAMBDA_EXECUTOR=docker-reuse` for 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. ## Sources - https://github.com/localstack/localstack - https://docs.localstack.cloud --- Source: https://tokrepo.com/en/workflows/8fa265fe-38ef-11f1-9bc6-00163e2b0d79 Author: Script Depot