Debug not works with "Sam local start-api" with "--debug-port" and "--warm-containers"
See original GitHub issueWith this command:
sam local start-api --template-file template.yml --region eu-west-1 --debug-port 5555 --warm-containers EAGER
and this launch.json
{
"name": "Attach to SAM CLI",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5555,
"localRoot": "${fileDirname}",
"remoteRoot": "/var/task",
"protocol": "inspector",
"stopOnEntry": false
}
my Visual Studio Code doesn’t attach to container, I have no error or log, simply after 5 seconds the debug’s topbar disappear. The terminal logs doesn’t show “Debugging listening on…” when I try lo execute an HTTP request.
All works fine removing --warm-containers param.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
sam local start-api - AWS Serverless Application Model
Specifies the Lambda function to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port , --debugger-path , and -- ......
Read more >AWS Serverless how to use "sam local start-api" to debug .net ...
I see command line arguments --debug-port, --debugger-path, --debug-args and --debug-function, but no example of how these can be used for .net ...
Read more >sam local start-api - Fig.io
--debug-function <text>, Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to -- ...
Read more >sam local start-api - Amazon Serverless Application Model
Specifies the Lambda function to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port , --debugger-path , and -- ......
Read more >AWS SAM local — debugging Lambda and API Gateway with ...
This post covers how to get local debugging working using breakpoints and an IDE from a fresh AWS ... sam local start-api —...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I also cannot start the debugger mode with or without the --warm-containers option
sam local start-api --warm-containers LAZY -p 3001 -d 9999
@CeccoCQ Regarding the original issue using
start-api
, I had to dive into the code a bit to find out the following:If the template contains several functions (could be generated functions besides your original lambda, such as log retention related lambdas), a warning will be output:
Warning: you supplied debugging options but you did not specify the --debug-function option. To specify which function you want to debug, please use the --debug-function <function-name>
What’s non-intuitive about this code path is that it will disable setting of the debug port rendering debugging useless in this case. If you have one function and don’t specifiy
--debug-function
AWS SAM will assume you meant to debug your one and only function, when using---warm-containers
the code path will disable debugging if the function being executed isn’t the one specified by--debug-function
, however the code uses different identifiers of said function to check, again rendering debugging useless, this honestly seems like a bug.To make sure you can debug your function use
--debug-function
with your current flags, but specify the function name as specified in your template, e.g:MyFunction1A65A8F
as opposed to justMyFunction