Debugging Lambda functions should be easy, right? You want to debug as you develop, using a standard editor (VSCode), a popular IaC framework (AWS CDK), and a widely adopted language (TypeScript).
The main challenges to wider serverless adoption is the developer experience itself.
The guide helps to set up a smooth, flexible debugging environment with AWS CDK TypeScript Projects in VSCode.
The sample project uses two different debugging options, one by running function locally and debugging locally using AWS SAM, and the other by running function remotely and debugging locally using Lambda Live Debugger.
The starter project provides a CDK configuration with an example resource stack (API Gateway -> Lambda -> SQS).
The developer experience is simplified with 4 main requirements: quick debugging, no deployment or hot-swap requirement, support for multi-developer environment, local debugging with remote resources.
The reusable CustomLambda construct is based on the CDK NodejsFunction, bundling with ESBuild and including Lambda Powertools. This saves crucial seconds when initiating the debug run.
AWS SAM to invoke the Lambda function locally provides quick debugging without running cdk synth every time.
Lambda Live Debugger offers the added benefit of validating permissions set up in CDK by running the Lambda functions remotely.
Lambda Live Debugger automatically reloads the updated code without the need to redeploy or restart the debugger.