hatellla
hatellla

Reputation: 5142

DLQ on Failed Task in Step Function

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?

Upvotes: 8

Views: 7753

Answers (2)

Deepanshu Aggarwal
Deepanshu Aggarwal

Reputation: 1

Just one thing you can redrive any step function from the failed step only. So if you try to redrive in this case, your step function's last step is SendToSQS which is not failed. And even if it is Failed, you want to redrive from GetMyRecords, so I don't think this is an apt solution.

Upvotes: 0

A.Khan
A.Khan

Reputation: 4002

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
      }
   }
}

Upvotes: 11

Related Questions