Skill 4.1.1

Debug code to identify defects

Key Concepts

Locally, the AWS SAM CLI can run functions with a debugger attached (sam local invoke -d 5858) so you can step through code in your IDE, and the AWS Toolkits for VS Code and JetBrains add Lambda debugging and AWS resource browsing.

In AWS, start with the error message and stack trace in CloudWatch Logs, then reproduce the problem with the same input event. Common defects include unhandled exceptions, missing environment variables, wrong data types and code that assumes state survives between invocations. Amazon Q Developer can explain errors and suggest fixes.