I have a workflow with a choice state that checks for a certain variable and that kicks off the previous step again if the condition was met, or move to the next step if not.
import stepfunctions
first_job = stepfunctions.steps.Pass('First job')
second_job = stepfunctions.steps.Pass('Second job')
check = stepfunctions.steps.Choice('Check first job')
check.add_choice(
rule=stepfunctions.steps.ChoiceRule.BooleanEquals(
variable='$run_me_again',
value=True
),
next_step=first_job
)
check.default_choice(second_job) # This could be set automatically
chain = stepfunctions.steps.Chain([first_job, check, second_job])
The last line wants to chain the different steps so that we can convert it to a workflow but this line raises an error:
ValueError: ... , State type `Choice` does not support method `next`.
Why does this raise an error? it makes sense to have downstream tasks after a choice state.
I got the example from here
Choice states don't support the End field. In addition, they use Next only inside their Choices field.
Also you can use "Default": The name of the state to transition to if none of the transitions in Choices is taken.
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-choice-state.html