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/healthList All Resources
bash
awslocal resource-groups list-resourcesS3 (Simple Storage Service)
List All Buckets
bash
aws s3 ls --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 lsCreate a Bucket
bash
aws s3 mb s3://my-bucket --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 mb s3://my-bucketList Objects in a Bucket
bash
aws s3 ls s3://my-bucket --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 ls s3://my-bucketUpload 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.txtDelete a Bucket
bash
aws s3 rb s3://my-bucket --endpoint-url=http://localhost:4566
# or with awslocal
awslocal s3 rb s3://my-bucketSQS (Simple Queue Service)
List All Queues
bash
aws sqs list-queues --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sqs list-queuesCreate 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-queueSend 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-queueDelete 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-queueSNS (Simple Notification Service)
List All Topics
bash
aws sns list-topics --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sns list-topicsCreate a Topic
bash
aws sns create-topic --name my-topic --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sns create-topic --name my-topicList Subscriptions
bash
aws sns list-subscriptions --endpoint-url=http://localhost:4566
# or with awslocal
awslocal sns list-subscriptionsPublish 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-tablesCreate 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=5Put 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-tableLambda
List All Functions
bash
aws lambda list-functions --endpoint-url=http://localhost:4566
# or with awslocal
awslocal lambda list-functionsCreate 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-roleInvoke 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.txtCloudFormation
List Stacks
bash
aws cloudformation list-stacks --endpoint-url=http://localhost:4566
# or with awslocal
awslocal cloudformation list-stacksCreate 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.yamlSecrets Manager
List Secrets
bash
aws secretsmanager list-secrets --endpoint-url=http://localhost:4566
# or with awslocal
awslocal secretsmanager list-secretsCreate 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-secretTips
- Use the
awslocalwrapper (if installed) to avoid typing--endpoint-url=http://localhost:4566every 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.