A Docker-based LocalStack environment that automatically provisions AWS infrastructure components based on configuration files. This project enables rapid development and testing of AWS services locally with minimal setup.
This project provides an automated infrastructure-as-code solution for LocalStack, allowing developers to define their AWS resources in a simple configuration file and have them automatically provisioned when the LocalStack container starts.
- βοΈ Configuration-Driven: Define all infrastructure through a simple
env-settingsfile - π Zero-Configuration Setup: Infrastructure is created automatically on container startup
- π Queue Creation with DLQ: Automatically creates SQS queues with dead letter queues for reliable message processing
- πͺ£ Bucket Creation: Provisions S3 buckets for object storage
- π’ Topic Creation with Subscriptions: Sets up SNS topics with queue subscriptions and optional filter policies
- Docker and Docker Compose
jq(optional, for JSON formatting):sudo apt install jq
Edit the env-settings file to define your AWS resources:
# SQS Queues (automatically created with DLQ)
FIRST_QUEUE_NAME=my-processing-queue
SECOND_QUEUE_NAME=my-notification-queue
# S3 Buckets
FIRST_BUCKET_NAME=my-app-storage
SECOND_BUCKET_NAME=my-backup-storage
# SNS Topics
FIRST_TOPIC_NAME=my-event-topic
# Topic Subscriptions (format: topic|queue|filter_policy)
FIRST_TOPIC_SUBSCRIPTION=my-event-topic|my-processing-queue|{ "eventType": ["user-action"] }
SECOND_TOPIC_SUBSCRIPTION=my-event-topic|my-notification-queue|{ "eventType": ["system-alert"] }
THIRD_TOPIC_SUBSCRIPTION=my-event-topic|my-processing-queuedocker compose upThe infrastructure will be automatically created based on your env-settings configuration.
Check LocalStack status:
curl http://localhost:4566/_localstack/info | jqView created resources:
# List all buckets
aws --endpoint-url=http://localhost:4566 --region us-east-1 s3api list-buckets
# List all queues
aws --endpoint-url=http://localhost:4566 --region us-east-1 sqs list-queues
# List all topics
aws --endpoint-url=http://localhost:4566 --region us-east-1 sns list-topics
# List all subscriptions
aws --endpoint-url=http://localhost:4566 --region us-east-1 sns list-subscriptionsThe env-settings file uses a simple key-value format to define AWS resources:
# Format: {PREFIX}_QUEUE_NAME={queue-name}
FIRST_QUEUE_NAME=my-processing-queue
SECOND_QUEUE_NAME=my-notification-queueEach queue is automatically created with a corresponding dead letter queue ({queue-name}-dlq) and configured with a redrive policy (maxReceiveCount: 3).
# Format: {PREFIX}_BUCKET_NAME={bucket-name}
FIRST_BUCKET_NAME=my-app-storage
SECOND_BUCKET_NAME=my-backup-storage# Format: {PREFIX}_TOPIC_NAME={topic-name}
FIRST_TOPIC_NAME=my-event-topic# Format: {PREFIX}_TOPIC_SUBSCRIPTION={topic-name}|{queue-name}|{filter-policy}
# Filter policy is optional - omit for no filtering
FIRST_TOPIC_SUBSCRIPTION=my-event-topic|my-processing-queue|{ "eventType": ["user-action"] }
SECOND_TOPIC_SUBSCRIPTION=my-event-topic|my-notification-queue|{ "eventType": ["system-alert"] }
THIRD_TOPIC_SUBSCRIPTION=my-event-topic|my-processing-queueWhile the automated setup handles most use cases, you can also manually interact with the created resources:
# Send a message to a queue
aws --endpoint-url=http://localhost:4566 --region us-east-1 sqs send-message --queue-url http://localhost:4566/000000000000/my-processing-queue --message-body "Hello World"
# Receive messages
aws --endpoint-url=http://localhost:4566 --region us-east-1 sqs receive-message --queue-url http://localhost:4566/000000000000/my-processing-queue
# Check DLQ for failed messages
aws --endpoint-url=http://localhost:4566 --region us-east-1 sqs receive-message --queue-url http://localhost:4566/000000000000/my-processing-queue-dlq# Upload a file
aws --endpoint-url=http://localhost:4566 --region us-east-1 s3 cp ./env-settings s3://some-important-bucket/
# List bucket contents
aws --endpoint-url=http://localhost:4566 --region us-east-1 s3 ls s3://some-important-bucket/
# Generate signed URL
aws --endpoint-url=http://localhost:4566 --region us-east-1 s3 presign s3://some-important-bucket/env-settings# Publish a message to a topic
aws --endpoint-url=http://localhost:4566 --region us-east-1 sns publish --topic-arn arn:aws:sns:us-east-1:000000000000:some-important-topic --message "Test message"
# Publish with message attributes (for filtering)
aws --endpoint-url=http://localhost:4566 --region us-east-1 sns publish --topic-arn arn:aws:sns:us-east-1:000000000000:some-important-topic --message "User action" --message-attributes '{"eventType":{"DataType":"String","StringValue":"user-action"}}'For detailed examples and advanced configurations, refer to the documentation:
- S3 Service Documentation - Object storage operations
- SQS Service Documentation - Message queue operations
- SNS Service Documentation - Pub/sub messaging
- DynamoDB Documentation - NoSQL database operations
- KMS Documentation - Key management service
- Route 53 Documentation - DNS service
- Initialization Details - Technical implementation details
βββ docker-compose.yml # LocalStack container configuration
βββ env-settings # Infrastructure configuration file
βββ scripts/
β βββ init-aws.sh # Automated infrastructure provisioning script
βββ docs/ # Service-specific documentation
βββ volume/ # LocalStack persistent data
To extend the infrastructure automation:
- Modify
scripts/init-aws.shto add new resource types - Update
env-settingsformat documentation - Add corresponding configuration parsing logic
This project serves as a learning experience with LocalStack. Feel free to:
- Add new AWS service configurations
- Improve the automation scripts
- Enhance documentation
- Share your use cases and improvements