Step Functions
What is a state machine? A state machine is an abstract model which decides how one state moves to another based on a series of conditions. Think of a state machine like a flow chart.
What is Step Functions?
- Coordinate multiple AWS Services into a serverless workflow
- A graphical console to visualize the components of your application as a series of steps.
- Automatically triggers and tracks each step, and retries when there are errors, so your application executes in order and as expected, every time
- logs the state of each step, so when things go wrong, you can diagnose and debug problems quickly
Step Functions has two types of State Machines:
Standard - general purpose Express - for streaming data
You can Execute Steps in Parallel
States are configured through Amazon States Language (JSON)
Use Case
Manage a Batch Job or Fargate Container
Submit a Batch Job to AWS Batch if job fails or succeeds notify via SNS
Run a Fargate Task if job fails or succeeds notify via SNS
Transfer Data Records
Load up a DyanmoDB table. Add each DynamoDB item to the queue As each Item is processed remove the item from they DynamoDB table When there are no more records report successfully complete
States
Pass State
Passes its input to its output, without performing work dummy/mock. Pass states are useful when constructing and debugging state machines.
Parameters key-value pairs that will be passes as input
Result a virtual task to be passed to the next state
ResultPath where to place the “output” of the virtual task
Task State
represents a single unit of work performed by a state machine.
A task performs work by:
- a AWS Lambda function
- You provide a Lambda ARN as the resource
- or passing parameters to the API actions of other services
- A supported AWS Service
- You pass the ARN as the Resource
- Parameters vary per service
- Lambda
- AWS Batch
- DynamoDB
- ESC/Fargate
- etc
- or using an activity
- enables you to have a task in your state machine where the work is performed by a worker that can be hosted anywhere
Choice State
adds branching logic to a state machine
Wait State
delays the state machine from continuing for a specified for a specified time
Succeed State
stops an execution successfully The Succeed state is a useful target for Choice state branches that don’t do anything but stop the execution
Fail State
stops the execution of the state machine and marks it as a failure
"FailState": {
"Type:" "Fail",
"Cause": "Overloading",
"Error": "WarpCore"
}
Because Fail States always exit the state machine, they have no Next field and don’t require an End field
Parallel States
can be used to create parallel branches of execution in your state machine The state machine does not move forward until both state execute
Map State
Allows the user to iterate over an array