Testing with LocalStack: AWS on your Laptop

On this page

If you build on AWS, you need **LocalStack**. It mocks almost every AWS service (S3, Lambda, DynamoDB, SQS) on your local machine via Docker, allowing for free, fast, and offline development.

Docker Compose Setup

YAML9 lines
version: '3.8'
services:
  localstack:
    image: localstack/localstack
    ports:
      - "4566:4566" # The single edge port
    environment:
      - SERVICES=s3,sqs,dynamodb
      - DEFAULT_REGION=us-east-1

Configure AWS SDK (.NET)

C#6 lines
var config = new AmazonS3Config
{
    ServiceURL = "http://localhost:4566",
    ForcePathStyle = true // Crucial for LocalStack S3
};
var s3 = new AmazonS3Client("test", "test", config);

Key Takeaways

  • Use `awslocal` CLI wrapper for convenience: `awslocal s3 ls`.
  • Great for testing IAM policies and infrastructure code (Terraform runs against it too!).

Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Written by

Nithin Mohan TK

Hello Namaste! 👋🏻 I'm an accomplished Enterprise Solution Architect & Engineering Leader with 20+ years of progressive experience architecting, building, and scaling transformative enterprise solutions. ⚜️ Solution Architect / AI & Cloud 📌 Galway, Ireland

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.