DEV Community

Sayed Naweed Rizvi
Sayed Naweed Rizvi

Posted on

LocalStack: Simulating AWS Locally for Faster Development and Testing

Working with AWS is powerful, but developing and testing cloud-native applications can be time-consuming, expensive, and error-prone — especially when you're deploying frequently just to test small changes.

That’s where LocalStack comes in.

LocalStack lets you run a fully functional local AWS cloud stack. It simulates key AWS services on your machine so you can prototype, build, and test against real APIs — without ever hitting the cloud.

This blog walks you through what LocalStack is, when to use it, how to get started, and a few real-world scenarios where it can save time and cost.


What is LocalStack?

LocalStack is an open-source tool that emulates a wide range of AWS services locally. It’s built for developers who want to avoid the friction of deploying to AWS just to verify whether something works.

It supports services like:

  • S3
  • DynamoDB
  • Lambda
  • API Gateway
  • SQS
  • SNS
  • CloudWatch (limited)
  • And many more

You can run it using Docker and interact with it using the AWS CLI or SDKs just like you would with the real AWS environment.


Why Use LocalStack?

1. Faster Feedback Loop

No need to wait for cloud provisioning. You can deploy, test, and debug in seconds.

2. Offline Development

Perfect for working in environments with limited or no internet access.

3. Cost Efficiency

Running AWS services locally during development avoids incurring unnecessary cloud bills.

4. Safe Testing

You can simulate failure scenarios and edge cases without impacting real infrastructure.


Getting Started with LocalStack

Step 1: Install Docker

LocalStack runs in a Docker container, so you need Docker installed and running.

Step 2: Pull and Run LocalStack

docker pull localstack/localstack
docker run -d -p 4566:4566 -p 4571:4571 localstack/localstack
Enter fullscreen mode Exit fullscreen mode

Step 3: Set Up Your AWS CLI

Configure your AWS CLI to point to LocalStack:

aws configure
Enter fullscreen mode Exit fullscreen mode

Use dummy credentials (LocalStack doesn't verify them):

AWS Access Key ID [None]: test
AWS Secret Access Key [None]: test
Default region name [None]: us-east-1
Enter fullscreen mode Exit fullscreen mode

Then set the endpoint URL when calling services:

aws --endpoint-url=http://localhost:4566 s3 mb s3://my-test-bucket
Enter fullscreen mode Exit fullscreen mode

Sample Use Case: Testing S3 Uploads

Let’s say you have an app that uploads files to S3. You can simulate that like this:

# Create a bucket
aws --endpoint-url=http://localhost:4566 s3 mb s3://demo-bucket

# Upload a file
aws --endpoint-url=http://localhost:4566 s3 cp sample.txt s3://demo-bucket/

# List contents
aws --endpoint-url=http://localhost:4566 s3 ls s3://demo-bucket/
Enter fullscreen mode Exit fullscreen mode

This gives you the exact same experience as AWS, without using real cloud storage.


What LocalStack Can’t Do (Yet)

While LocalStack is incredibly powerful, it’s not a 100% replacement for AWS:

  • Not all AWS services are fully supported
  • Some advanced features (like IAM roles, VPC configurations) are limited
  • Behavior may differ slightly from production under certain edge cases

Use it for development and early testing, but always validate final behavior in real AWS environments.


Conclusion

LocalStack fills a much-needed gap in cloud-native development. If you’re building apps that use AWS services, adding LocalStack to your workflow can significantly improve your speed, confidence, and local testing experience.

It’s not a replacement for real-world staging environments, but it’s a solid step toward more efficient and cost-effective development.

Try out setting up S3 bucket on LocalStack now, it's easy 👇

Top comments (0)