Search code examples
amazon-web-servicesaws-lambda

AWS Lambda - How to stop retries when there is a failure


I know that when a Lambda function fails (for example when there is a time out), it tries to run the function 3 more times again. Is there any way to avoid this behavior? I' have been reading the documentation, but didn't find anyting about this.

Thanks!


Solution

  • EDITED: It's now possible to change the lambda settings to disable retries (see announcement)


    Original answer:

    There isn't a way to disable retry behavior of Lambda functions. I suggest two options to deal with that:

    1. Make your Lambda able to handle retry cases correctly. You can use context.AwsRequestId (or corresponding field) that will be the same when a Lambda is retried.
    2. Put your Lambda inside a state machine (using AWS Step Functions). You can only then disable retries. This blog post I've written gives a more general explanation.