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.51k stars 1.17k forks source link

Why does aws-sam-cli not support debug mode on os runtime (provided.al2 / provided.al2023)? #7291

Open HLN177 opened 3 months ago

HLN177 commented 3 months ago

Hey,

As the title said, why does aws-sam-cli not support debug mode on os runtime (provided.al2 / provided.al2023)?

Currently I'm trying to use Golang to write lambda functions, and the current aws support for go is linux os runtime (provided.al2023).

And yes, aws-sam-cli does serve the Go lambda function by mocking a api gateway environment (using command like 'start-api').

I was trying to investigate is a way to debug Go lambda with 'Step-Through' break point stuff, and I was imagining is like maybe I could achieve this by using debug mode of sam-cli and delve debugger.

But it seems sam-cli doesn't support debug mode on os runtime. Why sam-cli doesn't have this feature and what is the difficulty?

Btw, does anyone know a way to make the 'step-through' break point debug for Golang at this case?

hnnasit commented 3 months ago

Hi @HLN177, thanks for opening the issue. I do see in the vscode toolkits docs page that debugging is supported for go1.x. Are you looking for a particular IDE to perform step-through debugging?

HLN177 commented 3 months ago

Hi @HLN177, thanks for opening the issue. I do see in the vscode toolkits docs page that debugging is supported for go1.x. Are you looking for a particular IDE to perform step-through debugging?

Hi @hnnasit, thanks for you reply.

At the moment, I am using vscode to develop go lambda function now. I did see this vscode toolkits and it seems this tool still only supports deprecated go1.X runtime, but the aws lambda only provide al2023 os runtime environment for Go now.

And yes, we could still use the old go1.X runtime for development and then use al2023 os runtime for production. However, this can lead to some follow-up problems due to inconsistency between the development and production environments.

And this isn't just a problem with go. Other languages that use the OS runtime in aws lambda, like C and rust, may also experience this problem as well.

Do you have any solution for this case?

hnnasit commented 3 months ago

Thanks @HLN177, I see what you mean. I'm marking this as a feature request.

HLN177 commented 3 months ago

Thanks @HLN177, I see what you mean. I'm marking this as a feature request.

Thanks for your help. May I ask when would this kind of feature be implemented in general? Actually I am trying to customize the source code of aws-sam-cli to achieve my requirement atm. I am think if I could build the docker image with a kind of debugger server and expose a debug port. Do you think it is a appropriate approach for this case?