I want to modify the Amazon EventBridge retry policy settings, and set up a dead-letter queue (DLQ) for failed invocations.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
Modify the length of time that EventBridge retries
EventBridge uses exponential back off and jitter or a randomized delay to resend the event for 24 hours and up to 185 times. To avoid failed invocations, you can modify the length of time and number of times that EventBridge retries in the target's retry policy settings.
Note: EventBridge retries responses with a 5## or 4## HTTP status code for up to 24 hours.
To use the EventBridge console to configure the target's retry policy, complete the following steps:
- Open the EventBridge console.
- Select your EventBridge rule.
- Choose the Targets tab, and then choose Edit.
- Expand the Additional settings tab.
- For Retry attempts, enter the custom value.
Note: For event rules with multiple targets, you must individually set up the retry policy for each target.
You can also run the AWS CLI put-targets command or RetryPolicy API to configure a retry policy.
EventBridge handles event errors in different ways. For example, EventBridge might not deliver an event when a target doesn't have the required permissions, or a target no longer exists. Or, EventBridge might not try to resend the event. Instead, EventBridge might drop the event or send it to a DLQ that you configured.
Configure an EventBridge DLQ
To prevent the loss of events because of a delivery failure, configure an EventBridge DLQ. The DLQ receives all failed events to process later.
Note: Before you configure a DLQ for a target, you must create an Amazon Simple Queue Service (Amazon SQS) queue. In Amazon SQS queue policy, add the necessary permissions for the EventBridge rule to invoke the queue. If you encrypt the Amazon SQS queue, then add Decrypt and GenerateDataKey permissions to the AWS Key Management Service (AWS KMS) key policy.
To configure a DLQ, complete the following steps:
- Open the EventBridge console.
- Select your EventBridge rule.
- Choose the Targets tab, and then choose Edit.
- Expand the Additional settings tab.
- In the Dead-letter queue section, select an option based on whether your DLQ SQS is in the same AWS account or a different account.
You can also run the AWS CLI put-targets command to configure a DLQ. For the DeadLetterConfig parameter, use the ARN of the SQS queue.
Retrieve error details from a DLQ
To confirm that the event rule sent the message to a DLQ, review the InvocationSentToDLQ metric.
If there's a message, then complete the following steps:
- Open the SQS console.
- Choose the queue that you use as a DLQ for your event rule.
- Choose Send and receive messages, and then choose Poll for messages.
- In the Messages section, open the message.
- Choose Attributes to determine why EventBridge failed to deliver a message to the target.
Note: The data in the Body tab is the payload that EventBridge sends to the target when the event delivery doesn't fail.
Related information
Monitoring Amazon EventBridge
EventBridge metrics