Debug Lamba’s faster with Live Lambda Debugger

About the Author

This article was originally written by Marko.
Marko is an AWS-certified professional and serverless advocate with over 20 years of experience in the industry. He has been passionate about serverless technologies since 2017. …


This content originally appeared on DEV Community and was authored by Thijs de Z

About the Author

This article was originally written by Marko.
Marko is an AWS-certified professional and serverless advocate with over 20 years of experience in the industry. He has been passionate about serverless technologies since 2017. Marko is also the author of the blog Serverless Life, where he shares insights on serverless architectures and best practices.

Intro

He has contributed to the open-source community with projects like Lambda Live Debugger and ServerlessSpy. His dedication to advancing serverless technology has earned him the title of AWS Community Builder.

Lambda Live Debugger is an open-source tool that elevates the serverless development workflow by eliminating the cumbersome redeployment cycle. It allows developers to debug their deployed Lambda functions locally while maintaining the same permissions as if the code were running in the cloud. With support for JavaScript, TypeScript, and any framework, Lambda Live Debugger addresses the common challenges developers face when working with serverless environments, enabling faster, more efficient debugging and development.

Why I Built Lambda Live Debugger

As a developer working in serverless environments, I often found myself frustrated with the slow and repetitive process of writing code, deploying it, testing, finding issues, and then redeploying. Serverless solutions promised efficiency but fell short when it came to rapid development and debugging cycles.

The goal of Lambda Live Debugger was simple: to allow seamless, real-time debugging of deployed Lambda functions, streamlining the process so developers can fix issues faster, without disrupting their workflow. I built it to solve my own frustrations and in doing so, realized that many developers working with serverless functions face the same challenges.

Related information: Amazon Lambda on srvrlss.io

Alternatives

A common alternative is to run your Lambda code locally within an IDE like VSCode, by invoking the Lambda handler like any regular function with a mocked event.

While running Lambda code locally with mocked events may work for simple cases, it has several limitations. First, you would need to spend time configuring the local environment and preparing a relevant mocked event.

Even with local testing, you won't be able to fully simulate IAM permissions or integrations with other AWS services such as DynamoDB, S3, or SNS. Additionally, you won't be able to fully validate the entire event-driven workflow, which is an important aspect of serverless applications.

In the end, if you have an issue on the system, you would need to replicate the exact event and environment through mocking to reproduce and troubleshoot the problem.

Multiple tools are also available that simulate AWS environments locally, but they often fail to replicate the actual cloud environment closely enough.

Related: 2 AWS Lambda Debugging Techniques: Local SAM and Docker-Based Approaches

How Lambda Live Debugger Works

Lambda Live Debugger connects your deployed functions to your local machine via AWS IoT. It intercepts requests, routes them to your local environment for real-time debugging, and then sends the responses back to the deployed Lambda in the cloud. This seamless integration allows you to inspect, step through code, and interact with your functions as if they were running locally but with full access to the cloud environment and permissions.

In case of any code changes, the debugger reloads your code instantly without the need for redeployment or restarting the debugger. For TypeScript functions, the tool automatically transpiles them into JavaScript.

Schematic overview of key components

Easy Configuration with the Wizard

One of the most convenient features of Lambda Live Debugger is the wizard, which simplifies configuration. The wizard configures essential parameters, such as AWS profile, region, and more.

The wizard automatically generates a configuration file and sets up your debugging environment in VSCode. With this setup, you can instantly start debugging by pressing F5, setting breakpoints, and inspecting variables directly in your IDE.

Seamless Switching Between Development Modes

Lambda Live Debugger lets you effortlessly switch between debugging and normal execution modes. Re-enabling debugging is just as fast, with no need for redeployment, unlike many alternative solutions.

Focus on the Lambdas That Matter

A key feature of Lambda Live Debugger is the ability to attach the debugger to only specific Lambda functions. This allows you to focus on debugging the exact areas of your system that need attention without the distraction of unrelated functions.

Observability Mode for Non-Intrusive Debugging

Developers usually use personal AWS environments to avoid interfering with shared development systems. However, when personal environments aren't available due to technical or organizational constraints, Observability Mode is the perfect solution.

Observability Mode allows you to debug AWS Lambda functions without altering their normal behavior. Requests are intercepted and sent to your local machine for inspection, while the deployed Lambda continues running as usual. This mode is ideal for debugging in real environments where you can't pause execution or modify the code. Lambda Live Debugger samples requests every 3 seconds by default, ensuring system performance isn't affected.

Flexibility to Support Any Framework

Lambda Live Debugger works seamlessly with popular frameworks like CDK, Serverless Framework v3, AWS SAM, and Terraform. It also offers the flexibility to support any custom setup by defining your own list of Lambda functions, or adjust code paths and transpilation settings as needed.

Conclusion

Lambda Live Debugger was created to simplify the serverless development process by enabling real-time debugging of deployed Lambda functions without the need for redeployment. Whether you are looking to troubleshoot bugs, refine logic, or test specific Lambda functions, Lambda Live Debugger provides a seamless integration into your workflow. With support for a wide range of frameworks and environments, it ensures that developers can debug efficiently, focus on delivering serverless applications.

For more information or to try it out, visit Lambda Live Debugger.

First published on srvrlss.io


This content originally appeared on DEV Community and was authored by Thijs de Z


Print Share Comment Cite Upload Translate Updates
APA

Thijs de Z | Sciencx (2024-10-14T02:55:00+00:00) Debug Lamba’s faster with Live Lambda Debugger. Retrieved from https://www.scien.cx/2024/10/14/debug-lambas-faster-with-live-lambda-debugger/

MLA
" » Debug Lamba’s faster with Live Lambda Debugger." Thijs de Z | Sciencx - Monday October 14, 2024, https://www.scien.cx/2024/10/14/debug-lambas-faster-with-live-lambda-debugger/
HARVARD
Thijs de Z | Sciencx Monday October 14, 2024 » Debug Lamba’s faster with Live Lambda Debugger., viewed ,<https://www.scien.cx/2024/10/14/debug-lambas-faster-with-live-lambda-debugger/>
VANCOUVER
Thijs de Z | Sciencx - » Debug Lamba’s faster with Live Lambda Debugger. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/14/debug-lambas-faster-with-live-lambda-debugger/
CHICAGO
" » Debug Lamba’s faster with Live Lambda Debugger." Thijs de Z | Sciencx - Accessed . https://www.scien.cx/2024/10/14/debug-lambas-faster-with-live-lambda-debugger/
IEEE
" » Debug Lamba’s faster with Live Lambda Debugger." Thijs de Z | Sciencx [Online]. Available: https://www.scien.cx/2024/10/14/debug-lambas-faster-with-live-lambda-debugger/. [Accessed: ]
rf:citation
» Debug Lamba’s faster with Live Lambda Debugger | Thijs de Z | Sciencx | https://www.scien.cx/2024/10/14/debug-lambas-faster-with-live-lambda-debugger/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.