Developing Solutions with AWS Step Functions Flashcards
Which questions will have an answer with Step functions
I want to retry failed tasks.
I want to sequence tasks.
I want to try/catch/finally.
I want to select based on data.
I want to run tasks in parallel.
What is AWS Step Functions
AWS Step Functions is a web service that enables you to coordinate the components of distributed applications and microservices using visual workflows.
It provides a way to coordinate components and step through the functions of your application.
It provides a graphical console to visualize the components of your applications as a series of steps.
The benefits of AWS Step Functions
- Productivity => Build Applications Quickly
- Agility => Scale and Recover Reliably
- Adaptability => Evolve Applications Easily
The words of Step Functions
State machine => Workflow template
Execution => Specific workflow based on a template
Task or State or State transition => Lambda function or activity
Activity => Handle for external output
Task token => ID for instance of activity
Heartbeat => Ping from task indicating that it is still running
Failure => When execution fails
Success => When execution succeeds
What JSON tag specifies the starting state
“StartAt” tag
How can we identify a terminal state
A state with “Type”: “Succeed”, “Type”: “Fail”, or “End”: true
The requirements of states
- They must have a Type field
- They can have an optional Comment field
- Each state (except a Succeed or Fail state) requires a Next field or, alternatively, can become a terminal state by specifying an End field.
- A Choice state may have more than one Next but only one within each Choice Rule. A Choice state cannot use End.
The State types
Task => A single unit of work
Choice => Adds branching logic
Parallel => Fork and join the data across tasks
Wait => Delay for a specified time
Fail => Stops an execution and marks it as a failure
Succeed => Stops an execution successfully
Pass => Passes its input to its output
Map => Run a set of steps for each element of an input array
A task can be…
- An activity consists of program code or a task that waits for an operator to perform an action or to provide input. You can host activities on Amazon EC2, on Amazon ECS, or even on mobile devices.
- A Lambda function is a cloud-native task that runs on AWS Lambda.
The Control logic states
- A Pass state (“Type”: “Pass”) simply passes its input to its output, performing no work. Pass states are useful when constructing and debugging state machines.
- A Choice state (“Type”: “Choice”) adds branching logic to a state machine. A Choice state must have a Choices field whose value is a non-empty array, whose every element is an object called a Choice Rule.
- The Parallel state (“Type”: “Parallel”) can be used to create parallel branches of implementation in your state machine.
- A Wait state (“Type”: “Wait”) delays the state machine from continuing for a specified time.
Detail of Choice state
A Choice state must have a Choices field whose value is a non-empty array, whose every element is an object called a Choice Rule.
A Choice state may have more than one Next but only one within each Choice Rule. A Choice state cannot use End.
A Choice Rule contains the following:
• A comparison – Two fields that specify an input variable to compared, the type of comparison, and the value to compare the variable to.
• A Next field – The value of this field must match a state name in the state machine.
Fail and succeed state differences
A Fail state (“Type”: “Fail”) stops the run of the state machine and marks it as a failure.
The Fail state only allows the use of Type and Comment fields from the set of common state fields. In addition, the Fail state allows the following fields:
• Cause (Optional)Provides a custom failure string that can be used for operational or diagnostic purposes.
• Error (Optional)Provides an error name that can be used for error handling (Retry/Catch), operational or diagnostic purposes.
A Succeed state (“Type”: “Succeed”) stops a run successfully. The Succeed state is a useful target for Choice state branches that don’t do anything but stop the run.