In this article, We will show you how you can use LocalStack to test AWS SQS (Simple Queue Service) on your local system.

LocalStack SQS

Video

What is LocalStack?

LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications. This means you can test AWS cloud resources locally on your machine.

Note: LocalStack supporting only AWS cloud stack.

LocalStack spins up the following core Cloud APIs on your local machine.

  • ACM, API Gateway, CloudFormation, CloudWatch
  • CloudWatch Logs, DynamoDB, DynamoDB Streams
  • EC2, Elasticsearch Service, EventBridge (CloudWatch Events)
  • Firehose, IAM, Kinesis, KMS, Lambda, Redshift
  • Route53, S3, SecretsManager, SES, SNS
  • SQS, SSM, StepFunctions, STS

Benefits of Using LocalStack

  • Reduce Cost
  • Test AWS Cloud Resource Locally
  • Learn AWS Cloud Resource Locally
  • Debug Locally

Let’s Start

We hope you have installed Docker on your system else you can check the following article to install Docker.

Make Sure, You have configured AWS CLI on your system. If not please read the following article.

Docker-Compose.YML

Note: Starting with version 0.11.0, all APIs are exposed via a single edge service, which is accessible on http://localhost:4566 by default. If you look into the following file we have used EDGE_PORT=4566.

In the above file, We are creating Single Service as below with default region ap-southeast-1

  1. SQS

If you run the following command

docker-compose up

You will see the LocalStack container is running successfully as shown below in the screenshot

How To Test Services

To check all the services type the following URL on your browser

http://localhost:4566/health
Loclstack SQS Docker Compose

So now, the SQS service is running on the local system with the help of LocalStack

Create SQS Queue Locally

Once your LocalStack container is running up. You can open a new terminal and create an SQS queue using the following command

aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name onexlab

The above command will create the SQS queue name onexlab in the LocalStack SQS service. You can see the SQS queue URL in the screenshot shown below

List SQS Queue

To check all the created queues in the LocalStack type the following command in the terminal

aws --endpoint-url=http://localhost:4566 sqs list-queues

Create SQS Queue Message

To create a new SQS Queue Message type the following command in the terminal

aws --endpoint-url=http://localhost:4566 sqs send-message --queue-url http://localhost:4566/000000000000/onexlab --message-body 'Welcome to SQS queue by Onexlab'

The above command will create a new message in the onexlab queue.

Read SQS Queue Messages

To read the SQS Queue Messages type the following command in the terminal

aws --endpoint-url=http://localhost:4566 sqs receive-message --queue-url http://localhost:4566/000000000000/onexlab

Delete SQS Queue

To delete, The SQS queue. Type the following command in the terminal.

aws --endpoint-url=http://localhost:4566 sqs delete-queue --queue-url http://localhost:4566/000000000000/onexlab

Thank you 🚀🚀🚀🚀🚀🚀

Teaching & Developing For Startups

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store