0

I'm trying to follow the instructions I found here for debugging a Python SAM application in VS Code

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging-python.html

I'm not sure why they don't use sam build in the expamle, and point to .aws-sam/build but that's what I'm attempting.

My launch.json looks like this:

{
    "version": "0.2.0",
    "configurations": [        
        {
            "name": "SAM CLI Python debug test",
            "type": "python",
            "request": "attach",
            "port": 5890,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}/.aws-sam/build",
                    "remoteRoot": "/var/task"
                }
            ]
        }
    ]
}

I'm triggering the Lambda's directly for now and so I'm invoking them like this:

sam local invoke -d 5890

I'm then putting a breakpoint at the beginning of the Lambda I find in the build folder, but when I start the debugger in VS Code it executes the Lambda without stopping at the breakpoint.

I created a GitHub repo with the test project I'm using and description of how I'm using it.

https://github.com/rupe120/aws-sam-python-debugging-test

Could someone help point me at what I'm missing in my setup?

Josh Russo
  • 3,080
  • 2
  • 41
  • 62

2 Answers2

0

So, the recommended way to do this is with the AWS Toolkit extension.

https://github.com/awslabs/aws-sam-cli/issues/1926#issuecomment-616600799

Josh Russo
  • 3,080
  • 2
  • 41
  • 62
0

So the docs suggest using a localRoot of "${workspaceFolder}/hello_world/build" (assuming one is using the Hello World template). However, it only works when removing the build at the end of the path:

"localRoot": "${workspaceFolder}/hello_world"

This way, I got it to work without the AWS Toolkit.

Tobias Feil
  • 2,399
  • 3
  • 25
  • 41