A state machine allows you to design and automate business processes and data pipelines by composing compute resources (like functions and batch jobs) and other AWS services into a workflow. State machines manage failures, retries, parallelization, and observability, so you can focus on your business logic.
When to use them
- ETL processes: State machines can ensure that long-running, multi-step ETL jobs execute in order and complete successfully.
- Microservice orchestration: You can use state machines to combine multiple functions into a responsive, serverless application.
Defining states
You define state machines using the Amazon States Language. This example shows a simple order payment flow composed of Lambda functions:
Retry example
This example shows a state machine that ties together a batch job and a function. The state machine is configured to retry only the upload step if it fails, since regenerating the report would be costly and unnecessary.
generateReport: A batch job that generates a report.uploadReport: A function that uploads the report.reportStateMachine: The state machine that orchestrates the workflow.
Referenceable parameters
The following parameters can be easily referenced using $ResourceParam directive directive.
To learn more about referencing parameters, refer to referencing parameters.
Arn of the state machine.
- Usage:
$ResourceParam('<<resource-name>>', 'arn')
AWS (physical) name of the state machine.
- Usage:
$ResourceParam('<<resource-name>>', 'name')