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),
    );
posta un mese fa92 visualizzazioni
2 Risposte
0
profile picture
ESPERTO
GK
con risposta un mese fa
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
ESPERTO
con risposta un mese fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande