Add handling for transient Lambda service exceptions
AWS Lambda can occasionally experience transient service errors. In this case, invoking
Lambda results in a 500 error, such as ClientExecutionTimeoutException
, ServiceException
,
AWSLambdaException
, or SdkClientException
. As a best practice,
proactively handle these exceptions in your state machine to Retry
invoking your
Lambda function, or to Catch
the error.
Lambda errors are reported as Lambda.
. To
retry a Lambda service exception error, you could use the following ErrorName
Retry
code.
"Retry": [ { "ErrorEquals": [ "Lambda.ClientExecutionTimeoutException", "Lambda.ServiceException", "Lambda.AWSLambdaException", "Lambda.SdkClientException"], "IntervalSeconds": 2, "MaxAttempts": 6, "BackoffRate": 2 } ]
Note
Unhandled errors in Lambda are reported as Lambda.Unknown
in the
error output. These include out-of-memory errors and function timeouts. You
can match on Lambda.Unknown
, States.ALL
, or States.TaskFailed
to handle these errors. When Lambda
hits the maximum number of invocations, the error is Lambda.TooManyRequestsException
.
For more information about Lambda Handled
and Unhandled
errors, see FunctionError
in the AWS Lambda Developer Guide.
For more information, see the following: