Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the number of retry attempts of AWS Lambda in serverless.yml?

In the AWS Console it is possible to configure the number of retry attempts the Lambda Function will make in case of failure:

enter image description here

Is there any parameter in serverless.yml that allows the user to set that configuration?

like image 705
Franco Piccolo Avatar asked Jan 21 '20 13:01

Franco Piccolo


People also ask

How many times does AWS Lambda Retry?

Lambda functions being invoked asynchronously are retried at least 3 times. Events from Amazon Kinesis streams and Amazon DynamoDB streams are retried until the Lambda function succeeds or the data expires.

How do I change the limit on my Lambda timeout?

You cannot increase the runtime to more than 15 minutes. The AWS Lambda limit page states the Function timeout is 900 seconds (15 minutes) . If you need more than 15 minutes of execution time you have to look at other services.

How do you stop Lambda retries?

To stop it from retrying, you should make sure that any error is handled and you tell Lambda that your invocation finished successfully by returning a non-error (or in Node, calling callback(null, <any>) . To do this you can enclose the entire body of your handler function with a try-catch.

Does AWS Lambda retry after timeout?

Short description. There are three reasons why retry and timeout issues occur when invoking a Lambda function with an AWS SDK: A remote API is unreachable or takes too long to respond to an API call. The API call doesn't get a response within the socket timeout.


1 Answers

[2020-09 updated answer] As of v1.78.0, serverless now supports maximumRetryAttempts (and maximumEventAge).

[2020-01 original answer] At the time of posting, Serverless Framework does not yet support the configuration of Lambda retry counts. Note that the underlying feature became available from AWS Lambda on Nov 25, 2019. It is being tracked by Serverless as issues/7012.

like image 178
jarmod Avatar answered Oct 04 '22 18:10

jarmod