AWS Step Functions¶
AWS Step Functions makes it easy to coordinate the components of distributed applications as a series of steps in a visual workflow. You can quickly build and run state machines to execute the steps of your application in a reliable and scalable fashion.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Create necessary resources using AWS Console or AWS CLI.
Install API libraries via pip.
pip install 'apache-airflow[amazon]'Detailed information is available Installation of Apache Airflow®
Operators¶
Start an AWS Step Functions state machine execution¶
To start a new AWS Step Functions state machine execution you can use
StepFunctionStartExecutionOperator
.
You can also run this operator in deferrable mode by setting deferrable
param to True
.
start_execution = StepFunctionStartExecutionOperator(
task_id="start_execution", state_machine_arn=state_machine_arn
)
Get an AWS Step Functions execution output¶
To fetch the output from an AWS Step Function state machine execution you can
use StepFunctionGetExecutionOutputOperator
.
get_execution_output = StepFunctionGetExecutionOutputOperator(
task_id="get_execution_output", execution_arn=execution_arn
)
Sensors¶
Wait on an AWS Step Functions state machine execution state¶
To wait on the state of an AWS Step Function state machine execution until it reaches a terminal state you can
use StepFunctionExecutionSensor
.
wait_for_execution = StepFunctionExecutionSensor(
task_id="wait_for_execution", execution_arn=execution_arn
)