LocalStack, an AWS alternative to local development

Spread the love

Amazon Web Services is one of the cloud service providers most used by companies, and therefore, its domain is highly demanded by developers.

However, although AWS offers a free tier with certain services available, prior registration is required with the respective associated billing. This is not always available to everyone, especially in less developed countries. The good news is that you can learn to work with some of the most demanded AWS services without having to have internet access, today we present: LocalStack.

What is localstack?

Specifically for me, that I come from a country with little internet access represented the possibility of being able to learn a technology unattainable at that time.

The creators define localstack on their GitHub page as:

A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline! LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications.

Localstack Project

LocalStack provides two versions, one free and one pro. The free one provides free of cost the following AWS services that you can run locally on your computer, and use it for application development.

  • 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

Localstack / SQS installation

The localstack installation process can be done with docker, all or some of the services can be installed. Depending on the service to be used, I recommend you put it into operation.

In particular, I only like to make available the services that I am going to use, for example in the following file docker-compose.yml we are going to make SQS operational.

 version: '3'
        image: localstack/localstack
        - "4576:4576"
        - SERVICES=sqs  
        - DOCKER_HOST=unix:///var/run/docker.sock
        - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"

Although the recipe is quite clear, it is important to highlight two elements:

  • In ports we expose the port of the services that we are referring to in services, in this case 4576 which is the standard port of SQS.
  • In services we refer to the services within the localstack / aws stack that we want to be made available.

After saving the previous recipe in a file named docker-compose.yml, to start the SQS service we move in the terminal to the directory that contains the .YML file and execute the command:

docker-compose up -d

The terminal/console should start the process of downloading the image from localstack and then it will launch it:

Creating network "sqs_default" with the default driver
Pulling sqs (localstack/localstack:)...
latest: Pulling from localstack/localstack
0974748c771a: Downloading [=>                                                
0974748c771a: Downloading [=>                                                
0974748c771a: Downloading [=>                                               
 0974748c771a: Downloading [=>                                               
 0974748c771a: Downloading [=>                                               
 0974748c771a: Pull complete
Creating sqs_sqs_1_f8f03d85d42a ... done

To verify if SQS is available we can verify that port 4576 is available, for this we can execute the command:

nc -zv 4576

If the following output is shown then it was successful:

Connection to 4576 port [tcp/*] succeeded!

You can also make use of Portainer to see that it is running. In this article I show you how to install and make Portainer operational.

SQS en ejecución, visualizado en Portainer

I hope this article is useful to you, in future articles we will see how to use SQS with Postman to send messages to the queue.

Leave a Reply

Your email address will not be published. Required fields are marked *