Open heitorlessa opened 2 years ago
Should be pretty straightforward with the new lambda_extension
. We could have a simple no-op service there.
Is it available as a cargo crate?
Not yet, but you can use it from git at the moment :)
lambda-extension = { git = "https://github.com/awslabs/aws-lambda-rust-runtime", branch = "master" }
Apparently you can just call /register RAPID API as an “internal extension” and you also get the SIGTERM Benefit without needing s Layer and such
On Thu, 27 Jan 2022 at 16:58, Nicolas Moutschen @.***> wrote:
Not yet, but you can use it from git at the moment :)
lambda-extension = { git = "https://github.com/awslabs/aws-lambda-rust-runtime", branch = "master" }
— Reply to this email directly, view it on GitHub https://github.com/aws-samples/graceful-shutdown-with-aws-lambda/issues/1#issuecomment-1023365342, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZPQBBAPHKQKO4MDYX34UDUYFTQPANCNFSM5M56QK6A . You are receiving this because you authored the thread.Message ID: @.*** com>
@heitorlessa could you explain what you mean by "call/register RAPID API as an internal extension"? I haven't found any other examples on the internet that explain how to read SIGTERM signals without registering an extension.
Thanks in advance!
@luigidragone96 an internal extension is a thread in a lambda function that talks to the extension API. We have some examples. I will post it here once I found it.
Thank you! The examples would be very useful. At the moment I am using the workaround using an AWS managed extension, in particular the new extension for get parameter and secrets from SSM.
This is for python. Put the code outside of your handler.
@bnusunny thanks for sharing this example. I tried to do something similar with a lambda in NodeJS but I get the error 403 "Extension registration closed already"
{"errorMessage":"Extension registration closed already","errorType":"Extension.RegistrationClosed"}
NodeJS lambdas don't support internal extensions?
Could you share your test code? Extension registration should happen during the init phase (before the handler function is called).
So we can't use the graceful shutdown if we don't use any external extensions? Is there a way to create a dummy extension in Node.js that would serve only to catch the SIGTERM signal in lambda handler?
Both external and internal extensions can enable graceful shutdown.
You can create an internal extension in node.js following the python example I posted above.
@bnusunny Thank you! Do you have an example of an internal extension written for Node.js, or maybe just a code example with some descriptions of what we should do and why?
Firstly, thank you for creating this repository. It's a great finding to know any External Lambda Extension gives customers the ability to handle SIGTERM signal.
It'd be great to have a dummy extension instead of Lambda Insights, since the latter can incur charges.