State Machine
Resource Overview
A State Machine represents an AWS Step Function. Step Functions are a way to compose tasks into long-running processes. The sequence of operations is described in a state machine definition, in which "task" states indicate a job to be performed, such as sending work to an AWS Lambda function or writing an item to a DynamoDB table.
Key Features of AWS Step Functions include:
- Zero administration; AWS manages the underlying resources on your behalf.
- Long-running workflows; the maximum duration of a state machine invocation is one year.
- Pricing is on a per-state-transition basis, so you pay only for actual use.
- Ability to handle error states with automatic retry logic.
Event Subscription
Event subscription wires (solid line) visualize and configure event subscription integrations between two resources.
State Machines can subscribe to events emitted from the following resources:
- Event Rule
- REST API
- Timer
A State Machine can be invoked in response to a Timer (at regular intervals or according to a schedule), via a POST event to a REST API endpoint, or by the appearance of a CloudWatch event on an Event Bus. You can also start a State Machine via the AWS SDK API, or from the AWS CLI.
The following resources can be invoked by State Machine "Task" states:
- Docker Task
- Function
- HTTP API
- Job Queue
- REST API
- State Machine
- Table
- Topic
Configurable Properties
Logical ID
The unique identifier used to reference this resource in the stack template. Defining a custom Logical ID is recommended, as it allows you to quickly identify a resource and any associated sub-resources when working with your stack in AWS, or anywhere outside of the Stackery Dashboard. As a project grows, it becomes useful in quickly spotting this resource in template.yaml
or while viewing a stack in Template View mode.
The Logical ID of all sub-resources associated with this Function will be prefixed with this value.
The identifier you provide must only contain alphanumeric characters (A-Za-z0-9) and be unique within the stack.
Default Logical ID Example: StateMachine2
IMPORTANT : AWS uses the Logical ID of each resource to coordinate and apply updates to the stack when deployed. On any update of a resource's logical ID (or any modification that results in one), CloudFormation will delete the currently deployed resource and create a new one in its place when the updated stack is deployed.
Save Definition In File
Enabling this option will save your state machine definition in a file on disk, along with the stack template. Disabling this option will cause Stackery to save your definition directly in the stack template, in the State Machine's "Definition" property.
Definition File Location
Specify the location of the state machine definition file.
State Machine Definition
This is a descrption in YAML of the different states that compose the State Machine. This definition is written in ASL, the Amazon States Language. The definition may also be written in JSON, but in that case Stackery will also display it in YAML for ease of editing. A reference to ASL may be found here. Stackery searches your definition for those states that have type "Task" and creates an attachment point in the resource, which can be wired to a resource such as a Lambda function that will perform the task.
IAM Permissions
When a task state is connected to a resouce, permission to access the resource will be granted to the AWS States service.
Metrics & Logs
Double-clicking a resource while viewing your stack's current deployment gives you access to your pre-configured resource properties, and the following metrics and logs:
- Invocation Metrics
- Execution Duration
- CloudWatch Logs
- X-Ray Traces
Related AWS Documentation
AWS Documentation: AWS::Serverless::StateMachine
AWS SDK Documentation: Node.js | Python | Java | .NET | Ruby | Go