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),
    );
質問済み 1ヶ月前92ビュー
2回答
0
profile picture
エキスパート
GK
回答済み 1ヶ月前
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
エキスパート
回答済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ