aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
755 stars 222 forks source link

[Question] Attach debugger to already running lambda image via sam local start-lambda #3515

Open pandarun opened 1 year ago

pandarun commented 1 year ago

Question

I have a case when i need to hit and set breakpoints in several different lambdas called from locally running step functions, is it possible?

I'm able to debug individual lambda with SAM CLI locally, but it manages debugger and passes events automatically.

My first attempt was to run lambda via

/usr/local/bin/sam local start-lambda  --template /home/user/projects/lambda-hands-on/lambda-hands-on/.aws-sam/build/template.yaml  --container-env-vars /tmp/e65e9da8-db42-4b03-9028-f0675e8122ee-debugArgs.json --debugger-path "/opt/Rider/JetBrains Rider-2022.2/lib/ReSharperHost" --host 0.0.0.0 --debug-port 46539 --debug-port 38233
Starting the Local Lambda Service. You can now invoke your Lambda Functions defined in your template through the endpoint.
2023-03-14 18:19:25 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:3001
 * Running on http://192.168.1.142:3001
2023-03-14 18:19:25 Press CTRL+C to quit
Invoking Container created from helloworldfunction:dotnet6-v1
Building image.................
Using local image: helloworldfunction:rapid-x86_64.

START RequestId: de42f6aa-6e72-446c-aa86-6d854bbaffbd Version: $LATEST
[Info] Waiting for the debugger to attach...
[Info] Timeout. Proceeding without debugger.
END RequestId: de42f6aa-6e72-446c-aa86-6d854bbaffbd

But i was unable to find relevant process in 'attach to Process...'

dominicbarnes commented 1 year ago

I am trying to figure this out as well, it looks like there is some logic internally to the AWS Toolkit that configures the debugger that isn't exposed via configuration.

I would like to be able to debug my Lambda functions not only for manual invocation (ie: sam local invoke) but also for a running server (ie: sam local start-lambda or sam local start-api).