Local debuggung Python lambda function (using pyenv / virtualenv)
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 807
- Avg merge
- 10h 12m
- Merged PRs (30d)
- 7
Description
## Problem
I can not get the local Lambda debugger to work
## Steps to reproduce the issue
1. Create Lambda function with `sam init`. Choose the HelloWorld sample applicaiton, name it HelloWorldFunction
2. Create Launch configuration
```
{
"name": "HelloWorld template",
"type": "aws-sam",
"request": "direct-invoke",
"invokeTarget": {
"target": "template",
"templatePath": "${workspaceRoot}/HelloWorldFunction/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"runtime": "python3.12",
"payload": {
"path": "${workspaceRoot}/HelloWorldFunction/events/event.json"
}
},
"sam": {
"buildArguments": [
"--debug"
],
"localArguments": [
"--debug"
]
},
},
{
"name": "HelloWorld code",
"type": "aws-sam",
"request": "direct-invoke",
"invokeTarget": {
"target": "code",
"lambdaHandler": "app.lambdaHandler",
"projectRoot": "${workspaceRoot}/HelloWorldFunction",
},
"lambda": {
"runtime": "python3.12",
"payload": {
"path": "${workspaceRoot}/HelloWorldFunction/events/event.json"
}
},
"sam": {
"buildArguments": [
"--debug"
],
"localArguments": [
"--template",
"${workspaceRoot}/HelloWorldFunction/template.yaml",
"--debug"
]
},
}
```
4. add `debugpy` to `requirements.txt`
5. Invoke `HelloWorld template` debug session
Log: https://pastebin.com/QheCQdep
6. Invoke `HelloWorld code` debug session
Log: https://pastebin.com/KKve3vzq
## Expected behavior
Debugging works
## System details (run the `AWS: About Toolkit` command)
OS: Darwin x64 23.2.0
Visual Studio Code extension host: 1.85.1
AWS Toolkit: 2.8.0
node: 18.15.0
electron: 25.9.7
Contributor guide
Research direction
Reproduce the issue with the HelloWorld sample, the two launch configurations, requirements.txt containing debugpy, and template.yaml. Start by reviewing the two linked logs and comparing the template and code debug sessions, including pyenv/virtualenv handling. Done means local debugging works for both configurations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript, vscode
- Domain
- cloud, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100