aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.5k stars 1.17k forks source link

Support runtime provided.al2 for debugging #3718

Open L4B0MB4 opened 2 years ago

L4B0MB4 commented 2 years ago

When developing a go lambda including a external extension one has to switch to provided.al2. If you want to debug the lambda with

sam local start-api --host 0.0.0.0 -d 5858 --debugger-path dlv --debug-args "-delveAPI=2"

it only works until it builds the docker image. image

How are we not supposed to debug this ?

Also (as a side note) I could have sworn it worked at one point. But after multiple colleagues had this problem I found myself unable to reproduce a working debugger as well - so it might be my dementia.

Any plans on supporting this in the (near) future ?

CoshUS commented 2 years ago

Instead of using the go emulation image, provided runtime will pull the provided lambda emulation image which does not support debugging. We currently don't have plans on supporting this. Tagging it as a feature request.

alijarjis-pol commented 2 years ago

I'd also like to see this feature implemented. Its very annoying that there is no way to debug a Go Lambda locally at the moment.

shearn89 commented 2 years ago

Developing on a mac and generally working on ARM lambdas, not being able to debug is certainly a problem!

ravitejaavv commented 1 year ago

Any update on this issue

ShankaranarayananBR commented 1 year ago

Any update on this issue??

mcblair commented 1 year ago

We use lambdas behind API Gateway, and use gin proxy. In order for us to debug our SAM functions in al2 runtime, we've implemented an abstraction that determines if running in AWS - if so, we call lambda.Start with gin proxy, if not, we call a localStart function that starts gin directly.

I'm not aware of any alternatives, but this at least allows us to debug a single function.

sbilello commented 1 year ago

@mcblair could you share a sample repository with an hello world lambda that are you able to debug in local in GoLand or VScode in an M1 Mac please?

mcblair commented 1 year ago

@sbilello Sure, just whipped this up: https://github.com/mcblair/aws-hello-go-lambda

It compiles, I have step-through debugged it in VS Code, on my M1 Mac with arm64. Can sam build and deploy it, too.

sbilello commented 1 year ago

@mcblair Thank you! It should be worth a blog post! I noticed it works nicely on VScode but unfortunately GoLand does not support provided.al2

mcblair commented 1 year ago

@mcblair Thank you! It should be worth a blog post! I noticed it works nicely on VScode but unfortunately GoLand does not support provided.al2

The AWS toolkit & SAM doesn't support provided.al2 for debugging lambdas. To debug that way, go1.x is required and you must debug from an x86_64 machine, M1 macs(or any arm chip) will not work (see https://github.com/aws/aws-sam-cli/discussions/4706).

I was debugging main with F5 in VS Code and stepping through. Debugging in GoLand should work the same way, as it isn't using AWS toolkit or SAM to even be aware of the function runtime.

andrewbohm commented 1 year ago

Are there any plans on supporting debugging on al2 in the future? Since aws is no longer going to support go1.x we are going to have to create all of our new functions with al2 and having the ability to debug would be nice to say the least.

jackmcguire1 commented 11 months ago

Bump

jledesma-tc commented 10 months ago

Bump