How do debug AWS SAM Local

Is there any guidance available on how to configure debugging when running AWS Lambda functions locally using AWS SAM Local?

8 comments
Comment actions Permalink

there is no guidance for it (no special support is provided), but the instructions for VSCode (https://github.com/awslabs/aws-sam-cli/blob/develop/docs/usage.rst#debugging-applications) should work for webstorm, too: you have to start the app in the way described in the doc and then create a run configuration of type "Attach to Node.js/Chrome", with port matching the port you pass to your app as --debug-port.

Note: when using Node.js versions < 7 (e.g. Node.js 4.3 and Node.js 6.10) choose the Node.js option, for Node.js versions including and above 7 (e.g. Node.js 8.10) use Chrome

0
Comment actions Permalink

Heads up link is dead

0
Comment actions Permalink

I would like to debug my python lambda function the same way mentioned. What do you recommend?

0
Comment actions Permalink

All I think about this fact is that I pay a good deal for this and VS code is free.  Ridiculous there isn't a Youtube video for by JB 
"Configuring  Webstorm for local AWS lamba with node"
"Configuring  Webstorm for local AWS lamba with Java"
... And if those videos do exist, they need to find a way to promote or SEO them better, 2 days looking for this page, a page with links and not a simple clear answer.

0
Comment actions Permalink

did you try using AWS Toolkit for WebStorm for running/debugging AWS Lambda functions as suggested in https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html?
Also, if you need running AWS SAM locally in debug mode, please follow the instructions at https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging.html#serverless-sam-cli-running-locally and then create a run configuration of type Attach to Node.js/Chrome, with port matching the port you pass to your app as --debug-port (-d).

0
Comment actions Permalink

STEP BY STEP GUIDE for Local Debugging with Node AWS Lambdas
For this to work It will be assumed you figured out how to make
template.yaml and event.json file (basically holds the json event that would go to your lambda).  And that you have installed and configured the AWS toolkit.


1. On the top menu click on :: "Run > Edit Configurations"

2. Click the "+" at the top right corner

3. Chose "AWS Lambda Local" from the drop down

( Look and the three tabs at the top.... Configuration, Sam CLI, AWS connection )
Go to the AWS Connection tab, it should already be filled out if you added the AWS toolkit with creds

Go to the Configuration tab, chose the From Template radio option,
First chose the radio button From Template, then navigate to a template.yaml file (assumed this was created)
skip down to where it says Input, choose the File radio button and select your event.json file (assumed this was created)

4. Click apply

5. To run it, On the top menu click on :: "Run > Debug[local] ............" it should be the second option or so

6. If you have any issues with npm not building , try going back to "edit configurations" , the "SAM CLI" tab and selecting "Build function inside a container"

helpful links : https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/run-debug-configurations-dialog-local.html

0

Please sign in to leave a comment.