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),
    );
feita há um mês92 visualizações
2 Respostas
0
profile picture
ESPECIALISTA
GK
respondido há um mês
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
ESPECIALISTA
respondido há um mês

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas