LocalStack
LocalStack is a cloud service emulator that runs in a single container on your laptop or in your CI environment.
localstack-cli Brew Installation
1 | brew install localstack/tap/localstack-cli |
Running LocalStack using CLI
You can run LocalStack using LocalStack CLI or Docker Compose
- LocalStack CLI
- Docker Compose
start LocalStack using CLI
1 | localstack start -d |
Query the status of services.
1 | localstack status services |
stop LocalStack
1 | localstack stop |
Running LocalStack using Docker Compose
1 | version: "3.8" |
How to connect with AWS CLI and SDKs
Manual configuration: Manually configure the SDK to connect to LocalStack services by setting the endpoint URL to http://localhost:4566 or http://localhost.localstack.cloud:4566. This can also be specified using a profile or an environment variable.
Configuring a custom profile
~/.aws/config
1 | [profile localstack] |
~/.aws/credentials
1 | [localstack] |
create a queue in LocalStack using AWS CLI
1 | aws sqs create-queue --queue-name MyQueue --profile localstack |
Get queue url
1 | aws sqs get-queue-url --queue-name MyQueue --profile localstack |
Delete queue
1 | aws sqs delete-queue --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/MyQueue --profile localstack |
List queues
1 | aws sqs list-queues --profile localstack |
List S3 bucket
1 | aws s3 ls --profile localstack |
Connect to LocalStack using Java SDK
1 | // Credentials that can be replaced with real AWS values. (To be handled properly and not hardcoded.) |