I recently discovered Localstack, which is a local AWS Cloud. You can develop and test your cloud apps directly on your PC locally and offline. It’s pretty handy if you working in a team and each of them need his own S3/SNS/SQS etc..
Windows docker setup
The easiest way to deploy it locally is by running the localstack docker container.
To let the localstack docker run on Windows, is it required to adjust the docker-compose.yml slightly by:
1 | version: '2.1' |
If the docker container is running, it will expose all the services on a different port. You can check here, on which port which service is running.
To use it, the only change you need to do, is to pointing the AWS cli/sdk that you would like to use your local instance.
You do it by setting the endpoint url parameter.
AWS CLI Examples
S3
Create a bucket
1 | aws --endpoint-url=http://localhost:4572 s3 mb s3://testbucket |
Copy a file to S3
1 | aws --endpoint-url=http://localhost:4572 s3 cp testfile.txt s3://testbucket |
Download a file from S3
1 | aws --endpoint-url=http://localhost:4572 s3 cp s3://testbucket/testfile.txt testfile.txt |
SQS
Create a Queue
1 | aws --endpoint-url=http://localhost:4576 sqs create-queue --queue-name testqueue |
After creating a queue, you will get an unique queue name (queue-url) , which you need to send/receive messages.
Send a message to the queue
1 | aws --endpoint-url=http://localhost:4576 sqs send-message --queue-url http://localhost:4576/queue/testqueue --message-body 'Test Message!' |
Read/Receive a message from the queue
1 | aws --endpoint-url=http://localhost:4576 sqs receive-message --queue-url http://localhost:4576/queue/testqueue |