Orchestrating Operational Workflows with AWS Step Functions
This lesson explains how AWS Step Functions orchestrates remediation, incident response and maintenance procedures that are too long or complex for a single Lambda function.
Learning outcomes
After completing this lesson, you will be able to:
- Describe state machines and state types.
- Choose between Standard and Express workflows.
- Monitor and recover failed executions.
State machines and states
A state machine is defined in Amazon States Language (JSON). States include Task (call a Lambda function or, through AWS SDK integrations, almost any AWS API directly), Choice (branch on data), Wait (pause for a time), Parallel and Map (process branches or items concurrently), Pass, Succeed and Fail. Each Task can have Retry rules with backoff and Catch rules that route errors to recovery states. The .waitForTaskToken pattern pauses until an external system or a person returns a token, which implements human approval steps.
The following diagram shows an operational workflow built from SDK integration tasks and a human approval step.

State types
Standard and Express workflows
Standard workflows run for up to one year with exactly-once execution and a full execution history, suitable for operational procedures and approvals. Express workflows run for up to five minutes at very high rates with at-least-once execution, suitable for high-volume event processing. Executions are started by EventBridge rules, Scheduler, API calls or other services, and the execution role needs permission for every integrated action. CloudWatch metrics such as ExecutionsFailed and ExecutionsTimedOut should be alarmed on.
| Need | Choice |
|---|---|
| Long procedure with waits and human approval | Step Functions Standard workflow |
| High-volume, short event processing | Step Functions Express workflow |
| Auditable AWS operational runbook with rate control across targets | Systems Manager Automation |
| Short custom action on one event | Lambda function |
Standard or Express?
Monitoring and recovering executions
Each Standard workflow execution keeps a detailed history in the console, showing every state's input, output and error, which is usually the quickest way to find why an execution failed. Express workflows do not keep this history, so they must send execution logs to CloudWatch Logs with a logging level of ALL, ERROR or FATAL. Both types can send traces to AWS X-Ray to show the time spent in each integrated service.
Errors have standard names that Retry and Catch rules can match. States.TaskFailed covers a failed task, States.Timeout a state that ran longer than its timeout, States.Permissions an execution role without the required permission, and States.ALL matches any error. When a Standard execution fails after a problem has been fixed, it can be redriven: the execution restarts from the failed state, keeping the results of the steps that succeeded, instead of running the whole workflow again.
Isolating a compromised instance
When GuardDuty reports a high-severity finding for an EC2 instance, the security operations team wants the instance isolated, evidence preserved and a human to decide whether to terminate it. An EventBridge rule on GuardDuty findings with severity of at least 7 starts a Standard workflow. Using SDK integrations without Lambda, the workflow tags the instance, replaces its security groups with an isolation group, detaches it from its Auto Scaling group, creates snapshots of its volumes, and waits for the snapshots to complete. It then sends an approval request through SNS with a task token and waits up to 24 hours. If approved, it terminates the instance; otherwise it leaves it isolated for forensic work.
"IsolateInstance": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:ec2:modifyInstanceAttribute",
"Parameters": {"InstanceId.$": "$.detail.resource.instanceDetails.instanceId",
"Groups": ["sg-0isolation"]},
"Retry": [{"ErrorEquals": ["States.ALL"], "MaxAttempts": 3, "BackoffRate": 2}],
"Next": "SnapshotVolumes"
}Which integration pattern pauses a workflow until a person approves?
Show answer
waitForTaskToken.
Exam Tips
Remember for the exam
- Step Functions orchestrates multi-step workflows with retries, catches, waits and parallelism.
- SDK integrations call AWS APIs directly without Lambda.
- waitForTaskToken implements human approval.
- Standard workflows run up to a year; Express up to five minutes at high volume.