2 minutes read

POSTED Dec, 2021 dot IN Serverless

How To Debug AWS Lambda Python Functions

Gokhan Simsek

Written by Gokhan Simsek

Software Engineer

Debugging is a lifesaver for Software Developers especially encountering a bug or peculiarities. Deprivation of such a great feature for AWS Lambda applications is one of the biggest problems. In this blog, we are going to explain step-by-step how to overcome this by using Thundra VSCode Debugger Extension.

Installing Thundra’s “AWS Lambda Debugger

After opening the project by Vscode, open the Extension panel from the left side and then type “Thundra” onto the search bar and install it.

AWS Lambda Debugger

Getting Thundra AWS Lambda Auth Key

To configure Thundra AWS Lambda Debugger, we need to get Thundra AWS Lambda Auth Key. Go to Thundra Login Page and login or Sign Up.

Thundra Signup

Afterlogging into your Thundraaccount, There are cards that explain Thundra Products separately. We can get our AWS Lambda Debugger Auth key from the Thundra APM card shown below. Just click the “Get your Auth Key” and then, copy your auth key from the popped-up modal.

Thundra APM

Opening Command Palette and Configuring Thundra Debugger

From the Left Bottom side of Vscode, Click the VSCode config settings icon and then, click the “Command Palette…” located top of the popped-up model. After clicking the “Command Palette…”, a modal will pop up at the top-center of VSCode. Typing “Thundra: Edit configuration” and press Enter.

settings icon

After entering the “Thundra: Edit configuration”, a tab like below should open. Type or Paste your auth key that is gathered by following the before step to the “<your_auth_token>”.

Thundra:Edit configuration

Configure Your Serverless Yml For Debugging

In order to debug your lambda, you should integrate the Thundra Python agent into your lambda environment. There are multiple ways to do this. In this section, I will just try to explain the serverless yml configuration. If you would like to take a look at other options, check out this link.

Step 1: Get Your Thundra API KEY from Thundra Website:

Go to Thundra Website and log in. Then, Click Use APM from the opening page.

Thundra API key

After clicking the “Use APM” button on the above screenshot, you are redirected to the Thundra APM Page. On this page, navigate your mouse icon on Profile that is located left-bottom of this screen.

Screen Shot 2021-12-07 at 17.02.02

From the pop up panel, click the “Projects” and copy your API KEY from the opening page corresponding to your project. Then, turning VSCode again.

Screen Shot 2021-12-07 at 17.02.15

Step 2: Install Thundra’s Serverless Plugin to Automatically Wrap Your Functions:

Before running the following instruction, Please make sure you have a package.json file. If not, first make “npm init” to create it.

npm install serverless-plugin-thundra

Step 3: Add Thundra's Serverless Plugin in serverless.yml File and Add ‘Thundra’ component to custom:

add API key

Step 4: Add the thundra_apiKey to Environment Variables under the Provider Section in serverless.yml:



Step 5: Add ptvsd layer to lambda that you would like to debug locally as shown below:

  • ${region} => your aws lambda region like eu-west-1, us-east-1 etc.
  • Check your timeout value. You might want to increase it for debugging.

increase timeout value

Open Your Lambda Function and Put a breakpoint

Put a breakpoint

Start Thundra AWS Debugger

Please make sure your lambda handler file is opened on VSCode, otherwise Thundra AWS Lambda Debugger throws an exception due to unrecognized runtime. While your lambda file is opened, open the “Command Palette…” and typing “Thundra: Start debugger” and press Enter.  

Thundra: Start debugger

Check Thundra AWS Debugger Connection

After “Start: Thundra Debugger” activated, a modal like below will pops up at the right-bottom corner of VSCode. Then, you can check your VSCode and Thundra Broker Connection.


Invoking your Lambda Function

After invoking your lambda function, Thundra AWS Lambda debugger hit the breakpoint and Voila! Now you can debug your lambda function.

hit the breakpoint


This blog explains step-by-step integration of Thundra AWS Lambda Debugger for VSCode. If you would like to get more information and see the advanced features of Thundra AWS Lambda Debugger, you can visit our websiteabout “Online Debugging for Serverless Python”. Also, you can check Thundra AWS Lambda Debugger VSCode Marketplace.