-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-lambda: rewrite handler name for provided.al2 #26573
Comments
Can you share your full CDK code for the lambda function? I am not sure if it's a good idea to allow CDK to "rename" the user file. |
The I imagine that at most it could be an extra flag or method that needs to be called to have that behavior. |
@valerena for such use cases the handler name would still be “bootstrap” so there is no impact. No extra flag is needed. |
@rittneje That's not correct. It's true that for custom runtimes Lambda always calls an executable called If you actually use a custom runtime in Lambda (let's say, Bash or PHP), the The fact that in Go your file needs to be |
@valerena It sounds like you are implying we can resolve this annoyance for by making a "fake" bootstrap script that just execs |
Unfortunately it's not that easy, because the Go executable is actually doing more than just "running" (it's starting a whole process that can handle multiple executions in a row interacting with Lambda Runtime API), it's actually "a custom runtime" but all included in the binary (that functionality coming from (It doesn't seem like a CDK question anymore, so I don't want to extend this too much) I think your initial suggestion is the right way to solve something like this, but you would have to implement it yourself for your use case instead of it being part of CDK. |
For anyone else that hits this issue, we were able to work around this flaw by creating a shell script named #!/bin/sh
set -euo pipefail
exec "${PWD}/${_HANDLER}" Note that the shell script must be executable. |
this helps alot @rittneje |
Lifesaver @rittneje ! |
Describe the feature
If a Lambda function is using the provided.al2 runtime, and has specified a handler other than "bootstrap", CDK should rename the handler file while creating the zip, unless there is also a file named "bootstrap".
It is acceptable but undesirable if an additional flag is needed to enable this behavior.
Use Case
If a repository houses multiple Go lambdas, naming all the binaries "bootstrap" as the provided.al2 requires is non-trivial. It would be better if CDK could just fix things automatically to work around the runtime's restriction.
Proposed Solution
No response
Other Information
No response
Acknowledgements
CDK version used
2.85.0
Environment details (OS name and version, etc.)
Alpine 3.18
The text was updated successfully, but these errors were encountered: