AWS Step Functions SDK: State type `Choice` does not support method `next`

Viewed 1561

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

1 Answers
Related