In case of Failed Task in step function, after trying with retry strategy, is there a way I can put these Failed tasks in some DLQ or something like that so that someone can monitor these messages later and redrive them after fixing the issue?
Asked
Active
Viewed 5,555 times
1 Answers
11
Yes you can catch the error after retry and send it to SQS. Here is an example.
{
"StartAt": "GetMyRecords",
"States": {
"GetMyRecords": {
"Type": "Task",
"Resource": "<resource arn>",
"TimeoutSeconds": 80,
"Retry": [
{
"ErrorEquals": [
"CustomError"
],
"IntervalSeconds": 300,
"MaxAttempts": 10,
"BackoffRate": 1.1
}
],
"Catch": [
{
"ErrorEquals": [
"CustomError"
],
"Next": "SendToSQS",
"ResultPath": "$.error"
}
],
"End": true
},
"SendToSQS": {
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage",
"Parameters": {
"QueueUrl": "https://sqs.us-east-1.amazonaws.com/123456789012/myQueue",
"MessageBody.$": "$.input.message",
"MessageAttributes": {
"MyAttribute1": {
"DataType": "String",
"StringValue": "Value of attribute 1"
},
"MyAttribute1": {
"DataType": "String",
"StringValue": "Value of attribute 2"
}
}
},
"End": true
}
}
}

A.Khan
- 3,826
- 21
- 25