Local Debugging
The stackery local invoke
command includes the following flags used to configure debugging:
--debug
--debug-args
--debug-port
--debugger-path
The values are passed through directly to the SAM CLI. Read the AWS docs on Step-Through Debugging Lambda Functions Locally for more information about configuring local debugging.
Only follow this guide once you have set up your local serverless development environment using our local development guide.
Integration with Debuggers
Setting up debugging in VS Code
To use VS Code's built-in debugger, add the following to your launch config file:
{
"name": "Attach to SAM CLI",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5656, // set the port to whatever you would like, but it has to match the port in the --debug-port flag
"localRoot": "${workspaceRoot}/src/getEvent",
"remoteRoot": "/var/task",
"protocol": "inspector",
"stopOnEntry": true
}
Then you can run:
stackery local invoke --stack-name local-demo --env-name test --function-id getEvent --debug-port 5656
Debugging in other editors
Debugging is supported in IDEs that have a debugging port. In WebStorm, you can set your debug port in the application's preferences. For debugging with Sublime Text, the Xdebug plugin allows for port configuration.
Check the documentation for your IDE to see if it supports local debugging ports.