I have a lambda function that runs over a period of ~10mins. Decently long for a Lambda but given our current needs/setup it's the simplest way for it to do what we need it to do.
However, a recent bug in our Lambda code made the lambda go haywire and basically DOS our own server. This is where I realized I have no idea how to kill this process if ever I need to (vs just wait for it to end/timeout). so...
Is there a way to do terminate a running lambda process from the AWS console? Is there a way to do it via AWS CLI?
You cannot kill a running lambda function. Though there is another way by which you can set concurrency limit to 0. This will stop it from starting any more executions.
How do you stop a running Lambda that is stuck in a recursive loop? Delete the function. Set the function concurrent execution limit to 0 while you update the code.
When you call exit() like that you are killing everything instead of returning from your function like the Lambda server expects. In other words, exit() is always going to result in that error message. You need to return from your function instead.
There's no way to kill a running lambda. However, you can set concurrency limit to 0 to stop it from starting any more executions
e.g.
$ aws lambda put-function-concurrency --function-name my-function --reserved-concurrent-executions 0
https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html
Following on from ubi's answer, you can also set the concurrency via the AWS console. Go to the Lambda you want to stop and click on the Throttle button:
You will get a modal explaining the concurrency will be set to 0 and no more Lambdas will run:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With