States - Amazon Step Functions
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

States

Individual states can make decisions based on their input, perform actions from those inputs, and pass output to other states. In Amazon Step Functions, you define your workflows in the Amazon States Language (ASL). The Step Functions console provides a graphical representation of your state machine to help visualize your application's logic.

Note

If you define your state machines outside the Step Functions' console, such as in an editor of your choice, you must save your state machine definitions with the extension .asl.json.

States are elements in your state machine. A state is referred to by its name, which can be any string, but which must be unique within the scope of the entire state machine.

States can perform a variety of functions in your state machine:

  • Do some work in your state machine (a Task state)

  • Make a choice between branches of execution (a Choice state)

  • Stop an execution with a failure or success (a Fail or Succeed state)

  • Pass its input to its output, or inject some fixed data into the workflow (a Pass state)

  • Provide a delay for a certain amount of time, or until a specified date and time (a Wait state)

  • Begin parallel branches of execution (a Parallel state)

  • Dynamically iterate steps (a Map state)

The following is an example state named HelloWorld that performs an Amazon Lambda function.

"HelloWorld": { "Type": "Task", "Resource": "arn:aws-cn:lambda:us-east-1:123456789012:function:HelloFunction", "Next": "AfterHelloWorldState", "Comment": "Run the HelloWorld Lambda function" }

States share many common features:

  • A Type field indicating what type of state it is.

  • An optional Comment field to hold a human-readable comment about, or description of, the state.

  • Each state (except a Succeed or Fail state) requires a Next field or, alternatively, can become a terminal state by specifying an End field.

    Note

    A Choice state may have more than one Next, but only one within each Choice Rule. A Choice state can't use End.

Certain state types require additional fields, or may redefine common field usage.

After you have created and run Standard workflows, you can access information about each state, its input and output, when it was active and for how long, by viewing the Execution Details page in the Step Functions console. For more information, see Viewing and debugging executions on the Step Functions console.

After you have created and run Express Workflow executions and if logging is enabled for your Express Workflow, you can access information about the execution in Amazon CloudWatch Logs or the Step Functions console. For more information, see Viewing and debugging executions on the Step Functions console.