Transitions - AWS Step Functions

Transitions

When you start a new execution of your state machine, the system begins with the state referenced in the top-level StartAt field. This field, given as a string, must exactly match, including case, the name of a state in the workflow.

After a state runs, AWS Step Functions uses the value of the Next field to determine the next state to advance to.

Next fields also specify state names as strings. This string is case-sensitive and must match the name of a state specified in the state machine description exactly

For example, the following state includes a transition to NextState.

"SomeState" : { ..., "Next" : "NextState" }

Most states permit only a single transition rule with the Next field. However, certain flow-control states, such as a Choice state, allow you to specify multiple transition rules, each with its own Next field. The Amazon States Language provides details about each of the state types you can specify, including information about how to specify transitions.

States can have multiple incoming transitions from other states.

The process repeats until it either reaches a terminal state (a state with "Type": Succeed, "Type": Fail, or "End": true), or a runtime error occurs.

When you redrive an execution, it's considered as a state transition. In addition, all states that are rerun in a redrive are also considered as state transitions.

The following rules apply to states within a state machine:

  • States can occur in any order within the enclosing block. However, the order in which they're listed doesn't affect the order in which they're run. That order is determined by the contents of the states.

  • Within a state machine, there can be only one state designated as the start state. The start state is defined by the value of the StartAt field in the top-level structure.

  • Depending on your state machine logic — for example, if your state machine has multiple logic branches — you may have more than one end state.

  • If your state machine consists of only one state, it can be both the start and end state.

Transitions in Distributed Map state

When you use the Map state in Distributed mode, you'll be charged one state transition for each child workflow execution that the Distributed Map state starts. When you use the Map state in Inline mode, you aren't charged a state transition for each iteration of the Inline Map state.

You can optimize cost by using the Map state in Distributed mode and include a nested workflow in the Map state definition. The Distributed Map state also adds more value when you start child workflow executions of type Express. Step Functions stores the response and status of the Express child workflow executions, which reduces the need to store execution data in CloudWatch Logs. You can also get access to flow controls available with a Distributed Map state, such as defining error thresholds or batching a group of items. For information about Step Functions pricing, see AWS Step Functions pricing.