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
Installation
To use AWS Lambda Debugger, you need to complete all installation steps. Please follow the instructions below.
-
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. -
Add this key to both your VS Code configuration and your AWS Console:
-
Open the Command PaletteĀ
(ā§āP)
Ā and selectĀ Thundra: Edit ConfigurationĀ command to paste the auth token to theĀauthToken
Ā field -
Go to your AWS Console and set your auth token value with theĀ
THUNDRA_AGENT_LAMBDA_DEBUGGER_AUTH_TOKEN
Ā key as your environment variable.
-
-
After installing the extension, instrument your AWS Lambda. You can do it in two ways.
-
Using Layers (easier)
-
Manual instrumentation
-
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.
-
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.