Set retry amount on a Lambda function

0

My understanding is that a Lambda function retry default is 2. That is if the function fails, Lambda will execute 2 invocations of the function.
Is there a way in the Python function to set the max reties on a specific Lamba function?

profile picture
Petrus
已提問 23 天前檢視次數 154 次
2 個答案
0
已接受的答案

Thank you Didier. This is what I was looking for! A succinct and direction answer. Appreciated!

profile picture
Petrus
已回答 22 天前
  • You should accept Didier's answer, not your own.

0

Hi Petrus,

This is the way to change the number of automatic retry for the async invocation of a Lambda with the CLI

aws lambda update-function-event-invoke-config --function-name error \
--destination-config '{"OnFailure":{"Destination": "arn:aws:sqs:us-east-2:123456789012:destination"}}'

It's all detailed on this page: https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html

In Python, you can do same with Lambda.Client.update_function_configuration(**kwargs): all details at https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda/client/update_function_event_invoke_config.html

response = client.update_function_event_invoke_config(
    FunctionName='string',
    Qualifier='string',
    MaximumRetryAttempts=123,
    MaximumEventAgeInSeconds=123,
    DestinationConfig={
        'OnSuccess': {
            'Destination': 'string'
        },
        'OnFailure': {
            'Destination': 'string'
        }
    }
)

MaximumRetryAttempts is the parameter that you want to configure

Best,

Didier

profile pictureAWS
專家
已回答 23 天前
profile picture
專家
已審閱 4 天前
profile picture
專家
已審閱 22 天前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南