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),
    );
preguntada hace un mes100 visualizaciones
2 Respuestas
0
profile picture
EXPERTO
GK
respondido hace un mes
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
EXPERTO
respondido hace un mes

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas