AWS Systems Architect Professional

AWS Step Functions Workflows, State Machines, and Orchestration – SAP-C02 Study Guide

Learn how AWS Step Functions orchestrates serverless workflows with state machines, branching, retries, waits, service integrations, and exam-focused design tradeoffs.

AWS Systems Architect ProfessionalAWS Systems Architect ProfessionalUpdated Sep 1, 2026
Study options
WatchComing later
ListenComing later
ReadAvailable
ReviewComing later

Study guide

Technical reference and lesson notes

Purpose of This Lesson

AWS Step Functions is a managed orchestration service for coordinating distributed application workflows. It lets you define a sequence of states, invoke AWS services such as AWS Lambda, apply branching logic, wait for a period, handle errors, and track execution progress.

Step Functions is especially useful when an application requires more control than a simple event trigger can provide. Instead of embedding orchestration logic inside one large Lambda function, the workflow is represented explicitly as a state machine.

Key Concepts

State machines and executions

A state machine is the definition of a workflow. It describes the states, transitions, inputs, outputs, and error-handling behavior.

An execution is a running instance of that state machine. Each execution has its own input, state transitions, output, and execution history.

A typical workflow might look like this:

  1. Receive an input event.
  2. Invoke a Lambda function to process the input.
  3. Evaluate the result with a Choice state.
  4. Follow a success or failure branch.
  5. Wait for a specified duration if required.
  6. Invoke another function or AWS service.
  7. End with Succeed or Fail.

Amazon States Language

Workflows are defined using Amazon States Language (ASL), a JSON-based language for describing state machines. The definition can be created or edited in the AWS Management Console, but infrastructure-as-code tools such as AWS CloudFormation, AWS CDK, and Terraform are generally preferable for repeatable deployments.

Common ASL state types include:

State typePurpose
TaskPerforms work by invoking Lambda or an integrated AWS service/API.
ChoiceBranches based on input or task output.
WaitDelays execution for a duration, timestamp, or input-derived value.
ParallelRuns multiple branches concurrently and waits for them to complete.
MapIterates over items, optionally processing them concurrently.
PassPasses or transforms data without calling an external service.
SucceedEnds successfully.
FailEnds unsuccessfully.

Data passing between states

Step Functions passes JSON data between states. A task can receive workflow input, perform work, and return a result for a later state. ASL fields such as InputPath, Parameters, ResultSelector, ResultPath, and OutputPath help control which data is selected, constructed, merged, or passed onward.

This makes it possible to keep each function focused on a specific responsibility while the state machine controls the overall sequence and data flow.

Branching and waiting

A Choice state implements conditional logic without requiring a Lambda function solely to evaluate a simple condition. For example, a workflow can inspect a processing status and route the execution to an approval branch or a notification branch.

A Wait state pauses the workflow for a fixed number of seconds, until a timestamp, or for a value provided in the input. This is useful for delayed processing, polling intervals, approval windows, and scheduled follow-up actions.

Error handling

Step Functions supports workflow-level error handling through Retry and Catch configuration on task states.

  • Retry repeats a failed task using configurable error matching, backoff, and attempt limits.
  • Catch routes an error to a fallback state, such as a compensation step, notification, or failure-handling branch.
  • A terminal Fail state makes an unsuccessful outcome explicit.

This is usually preferable to implementing all retry and branching behavior manually inside application code, but task operations should still be designed to be idempotent. A retry can cause the underlying operation to run more than once.

Service integrations

Step Functions can invoke Lambda and many AWS services directly through service integrations. Direct integrations can reduce the amount of coordination code and avoid using Lambda as a wrapper around an API call.

For example, a workflow might invoke an AWS Lambda function for custom business logic, call an Amazon DynamoDB API directly for persistence, or start an AWS Batch or Amazon ECS task for longer-running compute. The exact integrations and supported patterns depend on the service and Step Functions integration mode.

Standard and Express Workflows

Step Functions provides two workflow types:

CharacteristicStandard WorkflowsExpress Workflows
Best suited forLong-running, durable, auditable business processesHigh-volume, short-duration event processing
Execution historyDetailed execution history and visual trackingMore limited execution-history model; use logging and monitoring appropriately
Execution durationUp to one yearUp to five minutes
Delivery behaviorExactly-once workflow execution semantics, subject to task and integration behaviorAt-least-once or effectively-once processing considerations depending on mode and integration
Typical examplesOrder fulfillment, approvals, financial processingStreaming transformations, IoT or event-driven processing

Express Workflows have synchronous and asynchronous invocation modes. Choose the workflow type based on duration, throughput, execution-history requirements, and delivery semantics—not simply because one option is cheaper.

Exam-Relevant Takeaways

  • Use Step Functions when the main problem is orchestration, including sequencing, branching, waiting, parallel processing, retries, and error handling.
  • Use a Choice state for decision logic rather than creating a Lambda function for every simple yes/no decision.
  • Use a Wait state for delayed transitions instead of keeping a Lambda function running while it sleeps.
  • Use Parallel or Map when independent work can be performed concurrently.
  • Consider direct AWS service integrations to reduce unnecessary Lambda functions and custom glue code.
  • Design tasks for idempotency because retries, timeouts, client retries, or duplicate events can cause repeated operations.
  • Standard Workflows are the usual choice for durable, long-running, inspectable business processes.
  • Express Workflows are appropriate for short-lived, high-volume workflows where throughput and cost efficiency are important.
  • Step Functions provides orchestration, not general-purpose compute. The actual work is performed by Lambda, containers, AWS services, or other integrated systems.
  • State-machine definitions can be visualized in the console, but production definitions should normally be managed through infrastructure as code and version-controlled.

Architecture Decision Guide

RequirementRecommended approachReasoning
Coordinate several Lambda functions with branchingStep Functions Standard WorkflowMakes sequencing and decisions explicit and observable.
Delay a follow-up action for minutes or hoursWait state in Step FunctionsAvoids holding compute while waiting.
Retry transient downstream failuresRetry configuration plus idempotent task designCentralizes retry behavior and limits attempts.
Route failures to remediation or notificationCatch state transitionAllows a controlled fallback path.
Process many records independentlyMap state, possibly with distributed processingRepresents iteration and can provide controlled concurrency.
Run independent branches at the same timeParallel stateExpresses concurrent workflow paths.
Make a simple AWS API callDirect Step Functions service integrationAvoids a wrapper Lambda when no custom code is needed.
Run a high-volume, short-lived workflowExpress WorkflowOptimized for short executions and high event rates.
Run an auditable approval or fulfillment processStandard WorkflowProvides durable execution tracking and long-running support.
Implement a simple one-step event reactionLambda with an event sourceStep Functions may add unnecessary orchestration overhead.

Common Exam Traps

  • Confusing orchestration with choreography: EventBridge, Amazon SQS, and Amazon SNS help decouple event producers and consumers, but they do not by themselves provide a stateful, ordered workflow with branching and retries across multiple steps.
  • Using Lambda for waiting: A sleeping Lambda consumes runtime and can hit timeout limits. Use a Step Functions Wait state for workflow delays.
  • Assuming Step Functions performs the business work: Step Functions coordinates tasks; it does not replace Lambda, ECS, Batch, DynamoDB, or other services that perform the work.
  • Ignoring duplicate execution effects: A retry does not guarantee that a failed task had no side effects. Use idempotency keys, conditional writes, or transaction controls where appropriate.
  • Choosing Express for a long process: Express Workflows have a short maximum execution duration and are not the default choice for multi-day or highly auditable workflows.
  • Adding Lambda wrappers unnecessarily: If Step Functions can call the required AWS API directly, a wrapper function may add code, latency, permissions, and operational overhead.
  • Treating the visual graph as the deployment mechanism: The console visualization is useful for understanding and troubleshooting a workflow, but deployment should be controlled through versioned configuration and infrastructure as code.
  • Putting sensitive data everywhere in workflow input: State data can appear in execution history and logs depending on configuration. Minimize sensitive payloads and use references to protected data where appropriate.

Real-World Engineer Notes

  • Give each task a clear contract: expected input, output, timeout behavior, and retryable errors.
  • Use task timeouts so a stalled downstream dependency does not leave executions waiting indefinitely.
  • Make external side effects idempotent. For example, use a unique order or transaction identifier and conditional writes when creating records.
  • Keep workflow payloads small and pass object references, such as Amazon S3 keys, when large data must move between steps.
  • Separate business decisions from execution details. A Choice state can route based on a status returned by a task, while the task remains focused on producing that status.
  • Apply least-privilege IAM permissions to the state-machine execution role and to individual integrated services.
  • Monitor execution failures, timeouts, retries, throttling, and duration with Amazon CloudWatch metrics and logs. Standard execution history is particularly useful for diagnosing which state failed.
  • Consider compensation actions for partially completed workflows. For example, if inventory is reserved but payment fails, a failure branch may release the reservation.
  • Control concurrency for Map workloads to avoid overwhelming downstream services or exceeding service quotas.
  • Use Standard Workflows when operational staff need to inspect and replay or remediate individual business executions. Use Express when the workload is better treated as high-volume event processing and detailed per-execution history is less important.

Quick Reference Summary

  • Service purpose: Managed orchestration for distributed workflows.
  • Workflow definition: Amazon States Language, represented as JSON.
  • Primary building block: State machine.
  • Running instance: Execution.
  • Core logic: Task, Choice, Wait, Parallel, Map, Retry, and Catch.
  • Compute model: Step Functions coordinates work performed by Lambda, containers, Batch, and integrated AWS services.
  • Long-running and auditable: Standard Workflow.
  • Short-duration and high-volume: Express Workflow.
  • Most important design concern: Make task side effects idempotent and handle retries safely.
  • Operational benefit: Clear execution history and visual workflow representation.

Flashcards

  1. Q: What is AWS Step Functions primarily used for?

A: Orchestrating distributed application components as a stateful workflow with sequencing, branching, waiting, retries, and error handling.

  1. Q: What is a state machine?

A: The definition of a Step Functions workflow, including its states, transitions, inputs, outputs, and error behavior.

  1. Q: What is an execution?

A: A running instance of a state machine with its own input, progress, output, and history.

  1. Q: Which Amazon States Language state implements conditional branching?

A: Choice.

  1. Q: Which state pauses a workflow without consuming Lambda runtime?

A: Wait.

  1. Q: What is the difference between Retry and Catch?

A: Retry attempts the failed task again; Catch routes the failure to another state.

  1. Q: When should a Parallel state be used?

A: When independent workflow branches should run concurrently.

  1. Q: When is a Map state useful?

A: When the workflow must iterate over a collection and process each item, potentially with controlled concurrency.

  1. Q: Why must Step Functions tasks be idempotent?

A: Retries and duplicate delivery can cause a task’s side effect to occur more than once.

  1. Q: Which workflow type is designed for long-running, durable processes?

A: Standard Workflows.

  1. Q: Which workflow type is designed for short-duration, high-volume processing?

A: Express Workflows.

  1. Q: What is a benefit of direct service integrations?

A: They can invoke supported AWS APIs without requiring a Lambda wrapper.

Practice Questions

Question 1

A company processes customer orders through several stages: validate payment, reserve inventory, create a shipment, and notify the customer. Each stage may fail independently, and operations staff need to identify the exact stage and resume or remediate failed orders. Which architecture is most appropriate?

A. One Lambda function containing all processing logic
B. An Amazon SNS topic with independent subscribers and no workflow state
C. A Step Functions Standard Workflow with task states, retries, and failure branches
D. An Express Workflow with a five-minute execution limit

Correct answer: C

Explanation: A Standard Workflow provides durable orchestration, explicit sequencing, error handling, and execution visibility for a multi-step business process. The tasks should be idempotent so retries do not duplicate payments, reservations, or shipments.

Question 2

A workflow must wait 30 minutes after sending a customer approval request before checking whether the request was completed. Which design minimizes unnecessary compute consumption?

A. Invoke a Lambda function and use sleep for 30 minutes
B. Use a Step Functions Wait state
C. Poll continuously from an Amazon EC2 instance
D. Increase the Lambda function timeout and memory allocation

Correct answer: B

Explanation: A Wait state pauses the workflow without keeping a compute runtime active. The workflow can then transition to a status-checking task after the required delay.

Question 3

A Step Functions task creates a customer record in DynamoDB. The task times out after the write may already have succeeded, and Step Functions retries it. What is the most important design action?

A. Disable all retries for the workflow
B. Make the write idempotent using a stable identifier and conditional-write logic
C. Move the write into a longer-running Lambda function
D. Use an Express Workflow instead of a Standard Workflow

Correct answer: B

Explanation: A timeout does not prove that the side effect failed. A retry may repeat the write, so the operation should use an idempotency key or conditional expression to prevent duplicate records. Retry policy can still be retained for genuinely transient failures.

Question 4

A company receives a very high volume of short-lived events. Each event requires a workflow that completes within seconds, and the company does not need detailed long-term history for every execution. Which Step Functions option is the best fit?

A. Standard Workflow
B. Express Workflow
C. A Wait state lasting several hours
D. A single EC2 instance running a workflow scheduler

Correct answer: B

Explanation: Express Workflows are intended for high-volume, short-duration processing. The choice should still account for delivery semantics, monitoring requirements, and the five-minute execution limit.

Question 5

A workflow needs to call a supported AWS service API and then branch based on the API response. The development team proposes creating a Lambda function solely to call the API. What is the best recommendation?

A. Use a direct Step Functions service integration when supported
B. Replace Step Functions with an EC2-based scheduler
C. Put the API call in an Amazon SQS dead-letter queue
D. Use a Wait state before every API request

Correct answer: A

Explanation: Direct service integrations can remove unnecessary wrapper code, reduce operational overhead, and allow the state machine to handle the response and subsequent branching directly.