Running the Cloud on Your Desktop with LocalStack
Welcome back, perfect peeps! Today we’re diving deep into how to bring the power of AWS to your local machine using LocalStack. If you build cloud-native apps, dabble in side hustles as a solopreneur, or want to experiment with AWS services without racking up a bill, this is the post for you. You’ll learn what LocalStack is, why it’s awesome, and how to use it—from setting up buckets to working with Lambdas, CDK, CI/CD, and beyond.
Grab your favorite mug (mine’s a Netlify mug with way too much coffee in it), sit back, and let’s see how LocalStack can seriously change up your cloud development workflow.
Meet the Hosts: Catching Up
“I think it’s actually been about three years since you’ve been on the show, which is insane to me.”
If you’ve tuned in before, you’ll recognize your hosts from the DevRel (developer relations) world: Brian Reinaldi, previously at LaunchDarkly and now at LocalStack, and Alex, your guide here at CodingCat.dev.
Like so many of us, Brian juggles a full-time gig with a bunch of side projects (check out cfe.dev for his event lineup). Burnout happens, life gets busy, and conference schedules never slow down. But the passion for sharing cool tools survives! That’s why Brian’s here to give us the rundown on how LocalStack has changed his approach to both work and play.
What Is LocalStack?
If you’ve ever dipped your toes in AWS, you probably know the pain: spinning up resources is slow, can get expensive, and—let’s be honest—just plain scary when you’re learning. Enter LocalStack.
High-Level Overview
LocalStack is basically AWS on your laptop. You get a Docker image that emulates AWS services locally, so you can spin up buckets, run lambdas, use API Gateway, and much more—without ever touching your actual AWS account.
You don’t need to sign up for an AWS free tier. You don’t have to worry about forgetting to tear down an EC2 instance (and getting surprising bills). Instead:
- You experiment and build locally
- Everything is ephemeral
- You control costs (no “I left a GPU running all weekend” horror stories)
- Debugging, iteration, and CI/CD are all much, much faster
And you can reset and restart as often as you want.
Free vs Paid
LocalStack has two flavors:
- Open Source (Free)
- ~30 AWS services (S3, Lambda, API Gateway, CloudFront, etc.)
- Use as much as you want, forever
- Pro / Paid
- ~120 AWS services emulated (and counting)
- Premium features: more services, tools for debugging, step-through, chaos engineering, more
- This is how the LocalStack team eats (support them!)
Which Services Are Covered?
“We have like really close parity with AWS on certain services (like S3 & Lambda)... Some APIs are partial. But for core stuff, we’re very close.”
AWS itself has ~300 services, but most modern apps rely on a handful: S3, Lambda, API Gateway, DynamoDB, CloudFront. For these, LocalStack hits near parity with AWS. For edge-case services or those you almost never use, some features may lag behind.
Check out their full list of supported services to see if your stack is covered.
Main Features
Some of the headline goodies you’ll find in LocalStack:
- Run dozens of AWS services locally
- Step Debugging: Attach a debugger to your (Node.js) lambdas, set breakpoints
- Hot Reload: Save your code, instantly test the change, no manual deploys
- Chaos Engineering: Simulate API slowdowns, outages, or dropped packets to test how your app handles “the real world”
- Web-based UI: Inspect resources, invoke lambdas, and debug from your browser
- Thin Wrappers for CLI Tools: Keep your workflow—just redirect commands to “local”
“The real savings isn’t just the money. It’s the time you save as a developer. Tests that took 45 minutes now take just a few minutes.”
Setting Up LocalStack – Step By Step
Okay, let’s get hands-on. Here’s how to set up LocalStack on YOUR laptop, with tips straight from Brian and Alex.
The Docker Flow
LocalStack runs as a Docker container. So:
- Install Docker
- Pull LocalStack:
docker pull localstack/localstack
- Run LocalStack:
docker run -d -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack
- By default, LocalStack runs with GUI/API access on port
4566
. (Side note: multiple ports are used internally.) - Install the CLI wrapper (optional, but way easier):
pip install localstack-client
Or grab their LocalStack CLI for more features.
Web App UI: Not Just for the Cloud
Here’s something wild: LocalStack’s web UI runs on your laptop, but acts just like a cloud console.
What’s actually happening:
- The web app connects to your local Docker instance
- You browse buckets, lambdas, APIs…the whole works
- Everything is still 100% local to YOUR machine
“People actually get confused. They open the web app and think, ‘Wait, is this running in the cloud?’ Nope! It’s all on your box. But with all the power of a cloud console.”
Learning AWS for Real: Project Walkthrough
CDK, CloudFormation & Infrastructure as Code
To get serious with AWS, you’ll want Infrastructure as Code. Brian’s example uses CDK (Cloud Development Kit)—a tool that lets you build AWS resources in TypeScript, Python, etc., then transpile down to CloudFormation.
- CDK Stack: Write resources like
new s3.Bucket()
ornew lambda.Function()
in your preferred language. - Bootstrapping: CDK zips everything up, creates CloudFormation, and shoves it into S3 for deployment.
- Deploy: Actually builds resources locally—in our case, via LocalStack.
Workflow:
# Start LocalStack (make sure Docker is running)
localstack start
# Run CDK locally (not on AWS)
cdk-local bootstrapcdk-local deploy
If you’re used to writing TF with Terraform, this is a super similar flow.
Makefiles for Convenience
Brian uses a Makefile
to automate all his steps, like:
deploy-s3:cdk-local bootstrapcdk-local deploy
So he can just:
make deploy-s3
Easy button!
Example: S3 Static Site Hosting
Let’s walk through building a basic static site—think Netlify in the early days, just HTML/CSS/JS.
1. CDK Stack Definition
Here’s (roughly) what your TypeScript CDK stack might look like:
import * as s3 from 'aws-cdk-lib/aws-s3';
import { Stack, StackProps } from 'aws-cdk-lib';
class MyStaticSiteStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const bucket = new s3.Bucket(this, 'MySiteBucket', {
websiteIndexDocument: 'index.html',
websiteErrorDocument: 'error.html',
publicReadAccess: true, cors: [{
allowedMethods: [s3.HttpMethods.GET],
allowedOrigins: ['*'], }],
enforceSSL: true,
});
}
}
What’s going on?
- Defines an S3 bucket for static website hosting
- Enables public read, sets index/error documents, CORS, and SSL
- (Optionally) Uses S3 deployment to push static files into the bucket
Assets: Your /site-assets
folder holds index.html
, styles.css
, JS, etc.
2. Deploy Locally
With LocalStack running:
make deploy-s3
# or directly:
cdk-local bootstrapcdk-local deploy
3. Inspect in the Web UI
- Open the LocalStack web app
- Browse to the S3 bucket
- See your static assets:
index.html
, JS, CSS, etc.
4. Access the Hosted Site
LocalStack gives you a special URL pointing to your local instance, like:
https://bucketname.localstack.cloud:4566/index.html
Open in your browser. You’ll see your static site, served by a local clone of AWS S3.
Blockquote
“I'm doing this all locally. This is running, if you see that URL, it's actually pointing at your local instance... Not in the cloud, running on my machine.”
5. Bypass Annoyances
Working on the real cloud often hits you with CORS errors or IAM permission headaches. LocalStack lets you:
- Disable CORS for easier development
- Bypass IAM (security) during dev, then enable to test before pushing to prod
Read more on local AWS S3 restrictions.
From S3 to Global: Adding CloudFront
Let’s make things more “real world.” You want to deploy your site globally (via CDN) instead of from a single S3 bucket.
What’s New?
- Add a CloudFront distribution in your CDK stack
- CloudFront sits in front of your S3 bucket
- Disables public access on S3 (only CloudFront has access)
Access the CDN-Backed Site
The app is almost identical visually, but now served through a global CDN—and still completely local. Sound slow? Actually, on LocalStack, these setups build in seconds, not minutes.
“A CloudFront distribution can be super slow to deploy to AWS... This is going to deploy in a matter of seconds with Lambda, CloudFront, and S3.”
Serverless Power: Adding Lambdas
Static sites are fun, but sometimes you want server-side logic. Enter AWS Lambda.
1. Basic Lambda Example (Node.js)
Lambda handler file (e.g., src/handler.js
):
exports.handler = async (event) => {const response = {statusCode: 200,body: JSON.stringify({ message: "Hello from Lambda!" }),headers: { "Content-Type": "application/json" }};return response;};
2. Add Lambda to Your CDK Stack
import * as lambda from 'aws-cdk-lib/aws-lambda';const func = new lambda.Function(this, 'MyFn', {runtime: lambda.Runtime.NODEJS_18_X,handler: 'handler.handler',code: lambda.Code.fromAsset('src/')});
3. Expose via Lambda Function URL
You can create a public URL to hit your Lambda directly (for demos, not production!):
const fnUrl = new lambda.FunctionUrl(this, 'FnUrl', {function: func,authType: lambda.FunctionUrlAuthType.NONE,});
4. Deploy, Test, and Play
- Deploy with
make deploy-lambda
- LocalStack instantly exposes your
functionUrl
- Hit it in your browser or with
curl
:
curl https://function-id.localstack.cloud:4566/# => { "message": "Hello from Lambda!" }
5. Web UI FTW
Invoke the lambda, add debug payloads, and get instant feedback via the web app. No more click-wait-refresh nightmares!
API Gateway: Real-World Full Stack
Now, let’s build a real API like you’d use for your single-page app’s backend.
1. Integrate Lambda With API Gateway
Instead of exposing your lambda directly, route it through API Gateway.
import * as apigateway from 'aws-cdk-lib/aws-apigateway';const api = new apigateway.RestApi(this, 'MyAPI');const getIntegration = new apigateway.LambdaIntegration(func);api.root.resourceForPath('hello').addMethod('GET', getIntegration);
Now, when you hit /hello
on the API endpoint, it triggers your lambda!
2. Deploy & Call
make deploy-apigateway
Get the API endpoint (from CDK outputs or the web UI):
https://api-id.localstack.cloud:4566/hello
Visit in the browser or use your front-end code to call this endpoint.
3. Put It All Together
- S3 hosts the static site
- CloudFront sits in front as a CDN
- API Gateway exposes endpoints
- Lambda runs your server code
- All running locally
“This is now calling somewhat getting closer to a real app... not just a function URL endpoint, but an API, hit by the front-end.”
Bonus: Other AWS Services
Want more? LocalStack (even in the free version) supports:
- DynamoDB: Run a NoSQL backend locally for your app or play with familiar Dynamo queries
- SSM (Systems Manager) / Secrets Manager: Store environment variables, secrets, and config
- IAM: Simulate auth rules (can be turned off/on to make life easier in dev)
You can use thin wrappers for AWS CLI, CloudFormation, Terraform, CDK, and more.
Example CLI wrapper usage:
aws --endpoint-url=http://localhost:4566 s3 ls# Or use localstack's own CLI for extra features
“We even have a tool (Pro) called IAM Policy Stream that actually tells you what IAM policies you're missing for different services!”
Debugging, Hot Reload, and Chaos Engineering
Step Debugging
With Pro, add breakpoints to your serverless functions, use your favorite IDE, and step through lambdas—something most AWS users only dream about.
Hot Reload
Saving your lambda code triggers instant reload and redeploy. No more zip && upload && test
loops.
Chaos Engineering
Want to make sure your app doesn’t break if AWS throws a wrench in the works? LocalStack lets you simulate:
- Slow network calls (latency injection)
- Dropped packets (simulate outages)
- AWS API failures
Great for modern observability/testing practices!
“You’d be surprised how often packets are lost or latency spikes in the real world. Now you can test your resilience before you ship!”
LocalStack in Your Workflow: CI/CD & Team Dev
Developer Workflow
Picture this: Two developers are working on a feature, each running LocalStack on their laptops.
Workflow:
- Each dev spins up LocalStack locally
- Modifies CDK or Terraform code
- Tests lambdas, endpoints, etc., with full hot reload and step debugging
- Commits to git
CI/CD Pipeline Integration
Teams often spin up test environments on AWS for every pull request (expensive and slow). With LocalStack:
- CI/CD pipeline pulls your code
- Spins up LocalStack Docker container
- Deploys your full app to local stack in the CI runner
- Runs integration and unit tests (all local, zero cloud costs)
- If everything passes, deploys to AWS
Benefits
- No more “who forgot to shutdown the test instance?” bills
- CI builds run faster (tests go from 45min to 2min in some cases)
- Easy rollbacks (just restart local stack)
- Fast local feedback = more experimentation
Speed Gains
“It’s all faster! Unless you’re paying Buco bucks for your AWS builds, nothing beats your own dev laptop for speed.”
What’s Next for LocalStack? Beyond AWS
LocalStack started as “AWS locally,” but their dream is multi-cloud on your laptop.
GCP, Azure, and More
- Snowflake Emulator: Already in pre-release (for data science workflow fans)
- Azure: On the roadmap, with early experimental bits already out there
- GCP: No timeline yet, but definitely a future goal
- Custom Connections: Hook up LocalStack to third-party providers (like Okta, Auth0, etc.) easily
“Big vision: Whatever you do on the cloud, you should be able to do locally in LocalStack—across AWS, Azure, and GCP.”
Why Multi-Cloud?
Companies rarely stick with one provider forever. Multi-cloud is on the rise, and being able to test any cloud workflow locally is going to be a must.
Final Thoughts & Resources
After using LocalStack, Brian’s main takeaway is speed and freedom. It’s not just about saving money—it’s making cloud development fun to experiment with again.
“It let me experiment and iterate without all the pain and delay. Now I’m more likely to try new things, mess with new APIs, because it’s so fast and safe.”
All the demos we saw today (including Lambda, S3, CloudFront, API Gateway, and even DynamoDB) are included in the free version, so you can start experimenting without spending a dime.
Resources & More Reading
- LocalStack Docs
- CDK Intro
- AWS CloudFormation
- Terraform 101
- Working with Serverless on LocalStack
- CodingCat.dev Podcasts
For extra hands-on guides and new episodes:
- How to Deploy Full-Stack Apps to AWS the Easy Way
- Serverless Secrets: Deploy Lambdas in Seconds
- Intro to CI/CD for Startups
Join the Conversation
Have questions? Want to share your horror stories (or victories) using LocalStack? Hit us up at @CodingCatDev or drop a comment below!