AWS Lambda Debugging: Updated DockerContext causes debugger features to not work.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 807
- Avg merge
- 10h 12m
- Merged PRs (30d)
- 7
Description
- OS: MacOS Big Sur 11.5.2
- VS Code version: 1.61.2 Universal
- AWS Toolkit extension version: 1.33.0
**Question**
I am attempting to set up an environment to debug lambda functions locally. Previously I had created a temporary build directory with copies of relevant lambda handler code/modules and dependencies, which worked well.
In an effort to not create copies of existing code, I have been trying to configure my `launch.json`, `template.yaml` and `Dockerfile` to function without needing to create this temporary directory. Unfortunately, many of the required modules are located elsewhere in the repository in respect to the lambda handler code. The Dockerfile would not allow these modules to be brought in using the `ADD` functionality as they were originally out of the scope of the docker context. To get around this, I had update the `DockerContext` field in my AWS SAM template (`template.yaml`) to point to the root of the repository, allowing me to specify the paths to both the modules and the other related files such as the lambda handler and template, etc.
After creating my `launch.json`, running the debugger via Run -> Start Debugging works correctly, and the lambda handler is ran properly from start to finish, producing the correct output.
The issue appears when I try to set a breakpoint or use any of the debug tools during this process. Namely, the breakpoint set in the lambda handler code is present, but after starting the debugger via Run -> Start Debugging, it becomes disabled with the warning "Breakpoint in file that does not exist", despite this file clearly existing. Additionally, if you attempt to pause the execution of the lambda handler via the debug tools, it breaks completely.
Is there a way to configure this desired setup? With the `DockerContext` being set to a higher scope than where the lambda handler code and AWS SAM template exist? Or must the handler and template/dockerfile exist at the same level within the repository?
Thank you in advance!
Contributor guide
Research direction
Reproduce the local Lambda debugging setup using launch.json, template.yaml, and Dockerfile with DockerContext set to the repository root. Start by tracing how the configured context affects handler path mapping and breakpoint handling; done means breakpoints remain enabled and pausing works while the handler runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, vscode
- Domain
- cloud, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100