paint-brush
Debug your AWS Lambda in Production in just 5 stepsby@kantarci
541 reads
541 reads

Debug your AWS Lambda in Production in just 5 steps

by Burak KantarcıApril 9th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

By using AWS Lambda Debugger VS Code Extension, you can debug your serverless applications natively with their permissions.
featured image - Debug your AWS Lambda in Production in just 5 steps
Burak Kantarcı HackerNoon profile picture

Debugging means replaying the execution of an application in some means. Where in serverless applications, more specifically in AWS Lambda applications, replaying the same invocation is not always possible due to its black-box nature.


By using Thundra’s AWS Lambda Debugger VS Code Extension, you can debug your serverless applications natively with their permissions.

Benefits

  • No local issue reproduction, debug Lambda applications during the invocation execution.
  • Do not stop the whole process, debug/stop 1 Lambda invocation at a time.
  • No mocking resources and simulating the environments


Thundra Debugger Demo

Installation

To use AWS Lambda Debugger, you need to complete all installation steps. Please follow the instructions below.

  1. Install the extension from the marketplace.


  2. Sign up for Thundra and get your THUNDRA_AGENT_LAMBDA_DEBUGGER_AUTH_TOKEN. You can get your auth token from the start page if you've already signed up.


  3. Add this key to both your VS Code configuration and your AWS Console:


    1. Open the Command Palette (⇧⌘P) and select Thundra: Edit Configuration command to paste the auth token to the authToken field


      Thundra Debugger Demo

      Thundra Debugger Demo


    2. Go to your AWS Console and set your auth token value with the THUNDRA_AGENT_LAMBDA_DEBUGGER_AUTH_TOKEN key as your environment variable.


  4. After installing the extension, instrument your AWS Lambda. You can do it in two ways.

    1. Using Layers (easier)

      1. Guide for NodeJS
      2. Guide for Python
    2. Manual instrumentation

      1. Guide for NodeJS
      2. Guide for Python


How to use

  • Click on the “Start Thundra Debugger” button on the Status Bar. You can also execute the command Thundra: Start Debugger to start the debugging session.


Thundra Debugger Demo


  • Set a debug point on your VS Code. You can set multiple debug points as well.

  • Now invoke your AWS Lambda function to hit on the debug point.

  • When there is a hit on your breakpoint, the status bar below turns red.

  • You can start debugging when the variables and the call stack are loaded.

  • Debug session ends when your AWS Lambda function times out. You can update the timeout of your function for longer debug sessions.


Summary

Traditionally, it is impossible to put breakpoints in a Lambda function, stop the execution and debug as usual. Debugging serverless applications locally may make sense in some situations. But it is clear that mocking the cloud environment and debugging serverless applications locally misses some crucial points such as security permissions and authenticity of event data flowing between resources.


You can ease those pains by installing just a single VSCode extension, instrumenting your function without any further steps.