Codementor Events

How I learned that a lambda can't be stopped

Published Jun 15, 2019
How I learned that a lambda can't be stopped

I have to start this post by saying that I love AWS lambda. It makes my life easier as a developer when it comes to building applications.

I was writing code for a function by which the Lambda will invoke itself prior to timing out to finish with it's assigned processing task. This worked perfectly, but I wanted to stop my lambda at one point. I thought that setting the throttling option meant that no lambda could be run from that point forward, thus it would stop my lambda from invoking itself again after finishing its execution. Of course, this did not happen.

Throttling meant that at that point no function could be run, because the number of executing processes at the same time was set to 0. After reseting it to 1, that lambda continued its execution where it left off. The only way I could stop it was by redeploying my code with a sys.exit(0), which led to the successful termination of the lambda (with 3 retry attempts, but it worked!).

This is a small gotcha, but nevertheless a mind opener for me that day.

Discover and read more posts from Nada Jankovic
get started
post comments4Replies
Richard
6 years ago

Lukas
Do you need a re-deploy to remove invoke permission?

Nada Jankovic
6 years ago

If you remove the invoke permission in the IAM, you shouldn’t need a redeploy

Lukas S
6 years ago

Hello! Also a big lambda fan here. I ran into this some three years ago. The easiest and quickest solution to terminating runaway functions is to remove the invoke permission.

Nada Jankovic
6 years ago

I agree with you, didn’t think about that. Thanks for the suggestion!

Show more replies