Run a task despite the previous tasks failure or success in a step function

0

I have a scenario in step function where I need to execute a task after failure. below is the skeleton of the stepfunction code. but this is currently throwing TypeError for 'FAILED' status alone --> TypeError: (intermediate value).next is not a function? any idea how to execute a following task on failure and post that fail the step function

 const xyzPoller = new Pass(scope, 'Initialize', {
    parameters: {
      status: 'IN_PROGRESS',
      xyzLambdaTimeLimitSeconds: lambdaTimeLimitSeconds,
    },
  })
    .next(disableStreamTask)
    .next(xyzTask)
    .next(
      new Choice(scope, 'Has xyzTask finished?')
        .when(
          Condition.stringEquals('$.status', 'SUCCESS'),
          new Pass(scope, 'xyzTask Finished').next(enableStreamTask),
        )
        .when(
          Condition.stringEquals('$.status', 'FAILED'),
          new Fail(scope, 'xyzTask failed').next(enableStreamTask),
        )
        .otherwise(xyzTask),
    );
asked 15 days ago71 views
2 Answers
0
profile picture
EXPERT
GK
answered 15 days ago
0

Hi,

have you considered adding a Catcher to the state? See https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html

When a state reports an error and either there is no Retry field, or if retries fail to resolve the error, Step Functions scans through the catchers in the order listed in the array. When the error name appears in the value of a catcher's ErrorEquals field, the state machine transitions to the state named in the Next field.

profile pictureAWS
EXPERT
answered 15 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions