Running AWS locally with LocalStack

About

Running AWS locally with LocalStack

More and more companies are switching over to cloud native. As a developer this gives me a lot of services to create awesome applications. The one challenge that occurred to me right away was how to use all those new components during development. Since some companies do not have a testing/development environment in their cloud provider to play with. This was when LocalStack piqued my interest to simulate an AWS environment locally on my laptop or when running the CI/CD pipeline.

By Thomas de Groot

This blog will give a brief introduction in what LocalStack can do and how you can use it for your own projects.

What is LocalStack

LocalStack is a fully functional local AWS cloud stack that makes mocking/testing cloud applications simple by having everything start up local. With starting up LocalStack you are able to start up some core features of AWS like S3, DynamoDB, SNS/SQS and many more.

A single Docker container to rule them all

LocalStack can be started within a single docker container. It has quite some possibilities to edit some of the config. By setting the right environment variables you are able configure what service you want to enable and for some you can even set a random error rate for development purposes. The single container will be the host of the LocalStack application, to be able to reach certain services you need to address single edge service of LocalStack that is exposed by port 4566.

he edge serivce API of LocalStack is introduced by version 0.11.0. In previouse versions of LocalStack you needed to address a different port for each specific service (see here for the overview). Be warned the API-specific services may be removed in the future.

Example docker-compose.yml:

version: "2.1"
  services:
   localstack:
     image: localstack/localstack
     container_name: localstack
     ports:
       - "4566-4599:4566-4599" # ports of the different services
       - "9000:9000"
     environment:
       - SERVICES=sqs,dynamodb # a list of desired services you want to use.
       - DEFAULT_REGION=eu-west-1 # This is the region where your localstack mocks to be running
       - DATA_DIR=/tmp/localstack/data
       - PORT_WEB_UI=9000
       - LAMBDA_EXECUTOR=local
       - DOCKER_HOST=unix:///var/run/docker.sock
       - START_WEB=1

After running the docker-compose command below the container will be created and started and you are good to go!

Read the full article here.

Share
November 2024
December 2024
No event found!

Related Topics