LocalStack Commands Reference
LocalStack is a cloud service emulator that runs in a single container on your local machine, allowing you to develop and test your cloud applications offline. This page contains commonly used commands for interacting with LocalStack services.
Prerequisites
- AWS CLI installed
- LocalStack running (typically via Docker)
When using the AWS CLI with LocalStack, you'll need to add the --endpoint-url
parameter pointing to your LocalStack instance (usually http://localhost:4566
).
General Commands
Check LocalStack Health
bash
curl http://localhost:4566/health
List All Resources
bash
awslocal resource-groups list-resources
S3 (Simple Storage Service)
List All Buckets
bash
aws s3 ls --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 ls
Create a Bucket
bash
aws s3 mb s3://my-bucket --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 mb s3://my-bucket
List Objects in a Bucket
bash
aws s3 ls s3://my-bucket --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 ls s3://my-bucket
Upload a File to a Bucket
bash
aws s3 cp file.txt s3://my-bucket/ --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 cp file.txt s3://my-bucket/
Download a File from a Bucket
bash
aws s3 cp s3://my-bucket/file.txt . --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 cp s3://my-bucket/file.txt .
Delete an Object
bash
aws s3 rm s3://my-bucket/file.txt --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 rm s3://my-bucket/file.txt
Delete a Bucket
bash
aws s3 rb s3://my-bucket --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 rb s3://my-bucket
SQS (Simple Queue Service)
List All Queues
bash
aws sqs list-queues --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sqs list-queues
Create a Queue
bash
aws sqs create-queue --queue-name my-queue --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sqs create-queue --queue-name my-queue
Send a Message to a Queue
bash
aws sqs send-message --queue-url http://localhost:4566/000000000000/my-queue --message-body "Hello World" --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sqs send-message --queue-url http://localhost:4566/000000000000/my-queue --message-body "Hello World"
Receive Messages from a Queue
bash
aws sqs receive-message --queue-url http://localhost:4566/000000000000/my-queue --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sqs receive-message --queue-url http://localhost:4566/000000000000/my-queue
Delete a Queue
bash
aws sqs delete-queue --queue-url http://localhost:4566/000000000000/my-queue --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sqs delete-queue --queue-url http://localhost:4566/000000000000/my-queue
SNS (Simple Notification Service)
List All Topics
bash
aws sns list-topics --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sns list-topics
Create a Topic
bash
aws sns create-topic --name my-topic --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sns create-topic --name my-topic
List Subscriptions
bash
aws sns list-subscriptions --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sns list-subscriptions
Publish to a Topic
bash
aws sns publish --topic-arn arn:aws:sns:us-east-1:000000000000:my-topic --message "Hello World" --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sns publish --topic-arn arn:aws:sns:us-east-1:000000000000:my-topic --message "Hello World"
DynamoDB
List All Tables
bash
aws dynamodb list-tables --endpoint-url=http://localhost:4566
# or with awslocal
awslocal dynamodb list-tables
Create a Table
bash
aws dynamodb create-table \
--table-name my-table \
--attribute-definitions AttributeName=id,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--endpoint-url=http://localhost:4566
# or with awslocal
awslocal dynamodb create-table \
--table-name my-table \
--attribute-definitions AttributeName=id,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Put Item in a Table
bash
aws dynamodb put-item \
--table-name my-table \
--item '{"id": {"S": "123"}, "name": {"S": "test-item"}}' \
--endpoint-url=http://localhost:4566
# or with awslocal
awslocal dynamodb put-item \
--table-name my-table \
--item '{"id": {"S": "123"}, "name": {"S": "test-item"}}'
Scan a Table
bash
aws dynamodb scan --table-name my-table --endpoint-url=http://localhost:4566
# or with awslocal
awslocal dynamodb scan --table-name my-table
Lambda
List All Functions
bash
aws lambda list-functions --endpoint-url=http://localhost:4566
# or with awslocal
awslocal lambda list-functions
Create a Function
bash
aws lambda create-function \
--function-name my-function \
--runtime python3.8 \
--handler lambda_function.handler \
--zip-file fileb://function.zip \
--role arn:aws:iam::000000000000:role/lambda-role \
--endpoint-url=http://localhost:4566
# or with awslocal
awslocal lambda create-function \
--function-name my-function \
--runtime python3.8 \
--handler lambda_function.handler \
--zip-file fileb://function.zip \
--role arn:aws:iam::000000000000:role/lambda-role
Invoke a Function
bash
aws lambda invoke \
--function-name my-function \
--payload '{"key": "value"}' \
output.txt \
--endpoint-url=http://localhost:4566
# or with awslocal
awslocal lambda invoke \
--function-name my-function \
--payload '{"key": "value"}' \
output.txt
CloudFormation
List Stacks
bash
aws cloudformation list-stacks --endpoint-url=http://localhost:4566
# or with awslocal
awslocal cloudformation list-stacks
Create a Stack
bash
aws cloudformation create-stack \
--stack-name my-stack \
--template-body file://template.yaml \
--endpoint-url=http://localhost:4566
# or with awslocal
awslocal cloudformation create-stack \
--stack-name my-stack \
--template-body file://template.yaml
Secrets Manager
List Secrets
bash
aws secretsmanager list-secrets --endpoint-url=http://localhost:4566
# or with awslocal
awslocal secretsmanager list-secrets
Create a Secret
bash
aws secretsmanager create-secret \
--name my-secret \
--secret-string '{"username":"admin","password":"password123"}' \
--endpoint-url=http://localhost:4566
# or with awslocal
awslocal secretsmanager create-secret \
--name my-secret \
--secret-string '{"username":"admin","password":"password123"}'
Get a Secret Value
bash
aws secretsmanager get-secret-value --secret-id my-secret --endpoint-url=http://localhost:4566
# or with awslocal
awslocal secretsmanager get-secret-value --secret-id my-secret
Tips
- Use the
awslocal
wrapper (if installed) to avoid typing--endpoint-url=http://localhost:4566
every time. - For debugging, check the LocalStack container logs:bash
docker logs localstack
- To use a specific AWS region with LocalStack:bash
aws --region us-east-1 --endpoint-url=http://localhost:4566 s3 ls
- LocalStack Pro features may require additional configuration.