Debugging lambdas using the serverless framework + serverless-webpack.

2017-12-17

Our team has started to use the serverless-framework to create microservices. We have built API’s for basic CRUD features to full fledged ETL processes which pipe our microservice data back to our reporting database. This framework saves us a lot of time and gives us guidelines to organize our lambda’s and AWS resources into categorized services. We use the serverless-offline plugin to run our lambdas in a local environment and we use it alongside our test suite. One thing that we were missing with this framework was the ability to use visual studio debugging support with nodejs. It’s a beautiful thing to be able to see what’s going on in your app at runtime. As a team, we missed dropping in debugger.

We use the serverless-webpack plugin to bundle our project before we deploy to AWS. This initially appeared to add a layer of complexity to debugging. After reading through this thread however, we saw the light.

All we needed to do was update our webpack.config.js with devtool: 'source-map'. Here is a copy of our launch.json file which you can use within Visual Studio Code to get debugging support setup.

If you have any comments or questions please reach out on the gist’s provided or send me an email.