Starting State Machines

You can start a Step Functions execution using the following methods:
  • The Step Functions console.
  • The StartExecution API action.
  • Amazon EventBridge.
  • Nested workflows (triggering a workflow from another workflow).
  • Amazon API Gateway.
AWS Documentation

Integration Patterns

There are three integration patterns:
  • Request Response: Step Functions waits for the HTTP response and then progresses to the next step. It does not wait for the job to complete.
  • Run a Job (.sync): For certain services, Step Functions can wait for the job to complete before proceeding to the next state, using polling to check the job status.
  • Wait for a Callback with Task Token: Step Functions waits for the job to complete before moving to the next state. Instead of polling, it waits for the task token to be sent by the other service.
Standard workflows support all patterns, while Express workflows only support the Request Response pattern. Integration Patterns
AWS Documentation

Integration Overview

There are two ways to integrate AWS services with Step Functions:
  • AWS SDK Integrations: Call any AWS service from a state machine using API actions (supports over 200 services).
  • Optimized Integrations: API actions customized to provide enhanced functionality for workflows (supports about 20 services).
In both cases, you must use the Task state. Standard and Express workflows support the same integrations.
AWS Documentation

Call HTTPS API

You can call public or private APIs using the HTTP Task workflow state. An EventBridge connection is required for authorization and network connectivity. Calling HTTPS API
AWS Documentation

State machine

State machine (or workflow) - a series of event-driven steps (or states). Each step can call other AWS services or execute one of Step Functions' logic tasks (such as Wait, Choice, etc.). State machine
AWS docs

Workflow types

There are two workflow types:
  • Standard:
    • 2000 executions per second and 4000 state transitions per second.
    • Pay for the number of state transitions.
    • Easier to debug.
    • Supports "Run a Job" and "Wait for a Token" integration patterns (in addition to the request/response pattern).
    • Can run for up to one year.
    • Exactly-once execution.
  • Express:
    • 100,000 executions per second with nearly unlimited state transitions.
    • Pay for the number and duration of executions.
    • Only supports the request/response integration pattern.
    • Can run for up to five minutes.
    • At-least-once execution.
AWS docs

State

A state (or step) is a unit of work in the state machine. There are two types of states:
  • Flow state: Controls the logic of the workflow. Examples include Choice, Wait, Parallel, and Map states.
  • Task state: Executes an actual unit of work, such as making a call to another AWS service.
State machine
AWS docs

State structure

State machines are defined using JSON. States can occur in any order within the enclosing block, but their execution order depends on their configuration. Common state fields include:
  • Type: The type of state.
  • Next: The name of the next state.
  • End: Indicates a terminal state (true).
  • Comment: A description of the state.
  • Assign: Stores variables.
  • Output: Specifies and transforms the output from the state.
  • InputPath: Defines the input to process.
  • OutputPath: Defines the output to pass to the next state.
State structure
AWS docs

Transforming Data

Currently, there are two ways to define state machine transformations: JSONPath and JSONata (introduced at re:Invent 2024).
  • JSONPath: Use intrinsic functions in Pass, Task, Parallel, or Map states.
  • JSONata: A more flexible and concise method for transforming data.
AWS Documentation

Flow States

In a flow state, work is handled entirely by Step Functions, without requiring interaction with other AWS services. Flow States
AWS Documentation

JSONata and JSONPath

Use JSONata for new state machines. Consider the differences between JSONata and JSONPath to determine how and why to migrate. JSONata
AWS Documentation

Variables

Variables are used to store data for use in future steps. You can define and assign values to variables in Pass, Task, Map, Parallel, Wait, and Choice states. There is one reserved variable called $states, which contains:
  • The original input to the state.
  • The result of the state.
  • Error output.
  • The context object.
Variables
AWS Documentation

Handling Errors

There are two ways to handle errors in Task, Parallel, and Map states:
  • Retry: If an error encountered by the state matches an entry in the ErrorEquals list, the task will retry.
  • Catch: If an error encountered by the state matches an entry in the ErrorEquals list, the workflow will proceed to the task defined in the Catch block.
Handling Errors
AWS Documentation

Task Types

The Task state is the only state that performs actual work; all other Step Functions states handle workflow logic. Task types include:
  • Activity: A worker implemented and hosted by you (not supported by Express workflows).
  • Lambda Functions: Invokes a Lambda function.
  • Supported AWS Services: Calls API actions for supported AWS services.
  • HTTP Task: Calls an HTTP endpoint.
AWS Documentation

Activity

Set up a worker outside of Step Functions. An activity worker can be any application capable of making an HTTP connection, such as one running on an Amazon EC2 instance, an AWS Lambda function, or even a mobile device. Activity Workers
AWS Documentation

IAM

Step Functions does not support resource-based policies.
AWS Documentation