Getting Started with LocalStack: AWS Development Without the Cloud

Developing and testing AWS-based applications locally can be frustrating due to cost, latency, and connectivity issues. LocalStack solves this by providing a fully functional local AWS cloud stack so you can build and test your infrastructure offline.

In this post, we'll cover:

  • What LocalStack is

  • How to set it up

  • Common use cases

  • C#/.NET example with S3

  • Edge cases and gotchas

What Is LocalStack?

LocalStack is an open-source tool that emulates a wide range of AWS services on your local machine. It runs in Docker and supports services like:

  • S3, Lambda, API Gateway, DynamoDB, SQS, SNS, IAM, CloudWatch, and more.

With LocalStack, you can run your AWS infrastructure locally, making it easier to test without incurring costs or relying on cloud connectivity.

Setting Up LocalStack

Requirements

  • Docker is installed and running

  • Python & pip (for LocalStack CLI)

Installation

pip install localstack
localstack start

Or using Docker Compose (recommended):

# docker-compose.yml
version: '3.8'
services:
  localstack:
    image: localstack/localstack
    ports:
      - "4566:4566"  # Gateway to all services
      - "4571:4571"
    environment:
      - SERVICES=s3,sqs,lambda
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./.localstack:/tmp/localstack"

Run:

docker-compose up

Use Case: Working with S3 in .NET

Install the AWS SDK:

dotnet add package AWSSDK.S3

S3 Client Setup in C

var s3Client = new AmazonS3Client(
    new BasicAWSCredentials("test", "test"),
    new AmazonS3Config
    {
        ServiceURL = "http://localhost:4566",
        ForcePathStyle = true
    });

Create a Bucket and Upload a File

await s3Client.PutBucketAsync("my-test-bucket");

await s3Client.PutObjectAsync(new PutObjectRequest
{
    BucketName = "my-test-bucket",
    Key = "hello.txt",
    ContentBody = "Hello from LocalStack"
});

Verify with:

aws --endpoint-url=http://localhost:4566 s3 ls s3://my-test-bucket

Edge Cases and Gotchas

  • Credentials: Use dummy credentials like test/test — LocalStack doesn’t validate them.

  • Service URL: Always set ServiceURL = "http://localhost:4566".

  • ForcePathStyle: Required for S3 to avoid virtual host-style addressing.

  • Persistence: Use DATA_DIR in Docker Compose to persist state across restarts.

  • Feature Support: Not all AWS service features are supported (especially newer ones or deep integrations).

Summary

LocalStack is a powerful tool for local AWS development. It cuts costs, increases speed, and allows testing even offline. Whether you're building with Lambda, API Gateway, or S3, LocalStack can significantly improve your dev workflow.

References

0
Subscribe to my newsletter

Read articles from Renato Ramos Nascimento directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Renato Ramos Nascimento
Renato Ramos Nascimento

With over 14 years in software development, I specialize in backend systems using .NET, Python, and Java. I bring full lifecycle expertise, including requirements analysis, client/server and data layer development, automated testing (unit, integration, end-to-end), and CI/CD implementations using Docker, GitLab Pipelines, GitHub Actions, Terraform, and AWS CodeStar.