Transform Your Serverless Development: Simple AWS Lambda Debugging with LocalStack and VS Code

Share

Developing and testing serverless applications doesn’t have to mean racking up AWS costs or waiting on slow cloud deployments. With the LocalStack Toolkit for VS Code, you can emulate AWS services locally, deploy SAM applications, and even live debug Lambda functions—all without leaving your IDE.

This tutorial walks you through installing LocalStack, configuring your AWS profile, deploying a sample application, and debugging Lambda functions directly in VS Code.

Why Develop Locally with LocalStack?

Cloud-native development is powerful, but it comes with trade-offs. LocalStack helps you move faster and safer by offering:

  • Faster iteration – Local resources spin up instantly in memory.
  • Predictable cost – LocalStack has a fixed monthly plan (with a free tier), unlike AWS’s usage-based pricing.
  • Reduced friction – Skip organizational security gates and pre-deployment checks until you’re production-ready.
  • Broad service coverage – Emulation for 100+ AWS services, including Lambda, S3, DynamoDB, and SQS.

You still need AWS for production, but for development and testing, LocalStack saves time, money, and headaches.

Prerequisites

Before starting, make sure you have the following installed:

  • VS Code (latest version)
  • AWS Toolkit for VS Code (≥ v3.74)
  • LocalStack CLI and Docker image (≥ v4.8)
  • AWS SAM CLI (latest)
  • Python, JavaScript, or Java runtime (depending on your app)

Step 1: Install the LocalStack Toolkit for VS Code

The LocalStack Toolkit is a VS Code extension that simplifies managing the LocalStack emulator. You can install it in two ways:

  1. From the VS Code Marketplace.
  2. From inside AWS Toolkit’s Application Builder:
    • Open the AWS view in VS Code
    • Navigate to Application Builder → Walkthrough
    • Select Install LocalStack

This also helps install prerequisites like Docker and SAM CLI if needed.

Step 2: Install and Configure the LocalStack Emulator

Once the extension is installed, check the LocalStack status indicator at the bottom of VS Code:

  • Black → LocalStack emulator is already installed.
  • Red → Click to run the LocalStack Setup Wizard.

During setup:

  • You’ll sign in (or create) a LocalStack account (free forever).
  • A new AWS profile named localstack will be added to your ~/.aws/config and ~/.aws/credentials:
[profile localstack]
region = us-east-1
output = json
endpoint_url = http://localhost.localstack.cloud:4566

[localstack]
aws_access_key_id = test
aws_secret_access_key = test

Step 3: Create a Sample SAM Application

In the AWS Explorer view, click … → Create application with Serverless template.

  • Choose Process SQS Records with Lambda.
  • Select your preferred language (Python, JavaScript, or Java).
  • Use SAM as the IaC option.
  • Save it to a folder and name it sqs-lambda.

You’ll now see the code in VS Code. This application uses SQS as an event source for a Lambda function.

⚠️ If you’re on Intel, update template.yaml to set the Lambda architecture to x86_64 (the default example uses Graviton/ARM).

Step 4: Start LocalStack and Switch AWS Profile

  1. Start the emulator by clicking the LocalStack status icon → Start LocalStack.
    • It takes ~5 seconds (longer on first run as Docker images download).
  2. Switch to the localstack AWS profile:
    • Click the AWS profile indicator
    • Select profile:localstack.

Step 5: Deploy the Application to LocalStack

In the Application Builder, your sqs-lambda app will be detected.

  • Click Deploy SAM Application (cloud icon).
  • Deployment steps:
    • Deploy → Full Deployment
    • Specify requirements → Save defaults
    • Region: us-east-1
    • Stack name: sqs-lambda-stack
    • Choose: Create a SAM CLI managed S3 bucket

Deployment happens locally—fast and cost-free. Check AWS Explorer to confirm resources under account 000000000000 (LocalStack’s default).

Step 6: Debug a Lambda Function

Now for the fun part: live debugging a Lambda running in LocalStack.

  1. In Application Builder, refresh to see the deployed Lambda.
  2. Select the Lambda ARNInvoke Remotely.
  3. Enable Remote debugging.
  4. Select Event → SQS to auto-populate a test payload.
  5. Open the Lambda source code and set a breakpoint (e.g., at the start of a for loop).
  6. Click Remote Invoke.

The Lambda executes in LocalStack, pauses at your breakpoint, and you can:

  • Step through code
  • Inspect variables
  • Add more breakpoints

Just like local debugging, but emulating the AWS runtime.

Key Takeaways

  • The AWS Toolkit for VS Code now integrates with LocalStack, making local serverless development seamless.
  • You can:
    • Browse AWS resources locally in the Explorer
    • Deploy SAM projects without touching AWS
    • Debug Lambda functions remotely inside VS Code
  • LocalStack reduces development time, cuts AWS costs, and simplifies testing.

Conclusion

If you’re building with AWS Lambda, SQS, or other serverless services, LocalStack with VS Code is a must-have workflow. It allows you to shorten feedback loops by rapidly testing and deploying applications locally, reduces AWS costs by eliminating the need to spin up cloud resources during development, and debug functions with full visibility right inside your IDE. Best of all, this streamlined developer experience is available with LocalStack’s Free Forever plan, making it both accessible and cost-effective.

Read the Official Announcement from and guide from AWS Blog. You can also get started with LocalStack and supercharge your local AWS development today.


Share

Leave a Comment

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

Scroll to Top
×