AWS Step Function - Rerun one Step only

Viewed 721

I have a step function that failed in the last step, that's a lambda function that timed out. I could run the lambda only, but is there a way to run the last step of the step function (as in a retry for that particular step).

I don't want to rerun the whole thing, because the everything else is correct and relies on daily data. Thanks

1 Answers

Yes, you can retry an individual step function task.

This example retries a lambda task 2 times with backoff, including after a lambda timeout error:

{
  "StartAt": "LambdaTask",
  "States": {
    "LambdaTask": {
      "Next": "Success",
      "Retry": [
        {
          "ErrorEquals": ["States.ALL"],  // can also narrow this to specific errors - a timeout error is "Lambda.Unknown"
          "MaxAttempts": 2, // How many times to retry
          "IntervalSeconds": 2,  // How many seconds to wait initially before retrying.
          "BackoffRate": 3 // Multiplication for how much longer the wait interval gets on every retry.
        }
      ],
      "Catch": [{ "ErrorEquals": ["States.ALL"],"Next": "Fail"}
      ],
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "arn:aws:lambda:us-east-1:XXXXXXXXXX",
        "Payload.$": "$"
      }
    },
    "Success": { "Type": "Succeed" },
    "Fail": { "Type": "Fail" }
  }
}
Related