How to Test AWS Lambda locally. Local development for AWS Lambda is…

By Erik A. Ekberg

Erik A. Ekberg

Local development for AWS Lambda is usually coupled with an all-in-one framework like Serverless. These all-in-one frameworks breech the orthogonality of software design by tightly coupling your local development to other areas like your infrastructure provisioning or your CICD scripts. To avoid tight coupling in our infrastructure at ClickFlow we are using LocalStack: a Docker container that mimic AWS functionality in our local development environment.

💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline! (

Running LocalStack using Docker

Using the below Docker Compose file, run docker-compose up --build aws to start LocalStack.

Create and Invoke Lambda locally

Borrowing from AWS’s own NodeJS example, lets create an index.js file with the below code which will print data out to the console in LocalStack for use to see:

Now that we have created our lambda and have LocalStack running we need to create our local Lambda. LocalStack is compatible with AWS CLI to create, invoke, and delete Lambdas. After installing and configuring AWS CLI on your computer

Now, with LocalStack running we can run ./nodejs-example.bash to create local Lambda. Next, using AWS CLI we can also invoke our lambda like so: