Setup LocalStack For Local Environment

Kobe
2 min readNov 30, 2021

--

Keep my local development environment as close as possible to how it’s going to work in the real environment. Help us understand more about projects also easy to debug and speed up developing a new feature.

A few benefits of this approach are

  • You can run the lambda function locally
  • Don’t impact your team by sharing the same env ( update on the same buckets, same records )
  • Debug & Speed up your working
  • Don’t need to worry about paying for AWS usage for stupid action 🥰

Step 1: Initial Setup

First, we’ll need to install a few things

  1. Install Docker https://docs.docker.com/get-docker/
  2. Install the AWS CLI https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html ( required for localstack lookup a fake profile )=
aws configure
...
cat ~/.aws/credentials
[default]
aws_access_key_id = test
aws_secret_access_key = test
region = us-west-2
output = json

3. Check out the code from this repository https://github.com/kobee-tech-stack/aws-development-with-localstack

4. Install AWS CDK Local

npm install -g aws-cdk-local aws-cdk
or
yarn yarn global add aws-cdk-local aws-cdk

cdklocal --version 1.117.0 (build 0047c98)

Step 2: Starting our localstack container

At the root repository, you can see a folder “localstack” go to this folder and execute the command docker-compose up -d after waiting for minutes

cd localstack
docker-compose up -d

# Open browser and access the link for checking http://localhost:4566/health

Step 3: Deploy AWS Service to Localstack container.

At the root folder execute the command yarn deploy

IAM Statement Changes ...

(NOTE: There may be security-related changes not in this list. See https://github.com/aws/aws-cdk/issues/1299)

Do you wish to deploy these changes (y/n)?

#### Type `y` and see our stack

ApplicationStack: deploying...
ApplicationStack: creating CloudFormation changeset...


✅ ApplicationStack

Stack ARN:
arn:aws:cloudformation:us-west-2:000000000000:stack/ApplicationStack/e67d04e2

After the stack was deployed successfully — Try to recheck your deployment

Simple check your dynamo tableaws --endpoint-url=http://localhost:4566 dynamodb list-tables

Useful Tools for our development

S3 Viewer (MAC & Win)

https://cyberduck.io/

DynamoDB Viewer (MAC & Win)

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.settingup.html

SQS (Sender)

https://github.com/kobee-tech-stack/sqs-viewer

If you have any questions or issues when you try to deploy the stack let me know in the comments.

--

--

Kobe
Kobe

Written by Kobe

I’m working at KMS-Technology company. I love code (▀̿Ĺ̯▀̿ ̿) — Full Stack Software Engineer

No responses yet