# State Machines

State machines model a process as defined states and rules that determine how execution moves between them.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/state-machines

> A state machine makes process status, permitted transitions, and completion conditions explicit rather than hiding them in application control flow. In cloud architectures, state machines commonly coordinate distributed tasks, making workflows easier to recover, monitor, and scale independently of the services performing the work.

Practice exams covering State Machines: [SAA-C03 AWS Certified Solutions Architect - Associate](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate).

## 6 key aspects of State Machines

State machines make process flow explicit, while suitable orchestration engines add durable coordination, controlled concurrency, failure handling, and execution visibility.

1. **Explicit states and transitions**: Define valid process stages and the events or conditions that connect them. This makes success paths, rejection paths, and terminal outcomes reviewable and testable.
2. **Separation of coordination and execution**: Keep sequencing and branching in the workflow while independent workers implement business operations. Workers can evolve and scale separately, although their interfaces must remain compatible with the workflow.
3. **Durable execution and waiting**: A durable orchestration engine preserves workflow progress across interruptions and can wait for timers or external completion signals. Confirm the selected engine's persistence, retention, and maximum-duration guarantees.
4. **Explicit failure handling**: Model retries, timeouts, error branches, and compensating actions as part of the process. Use bounded retries and idempotent operations so recovery does not create duplicate business effects.
5. **Branching and controlled concurrency**: Use conditions to select execution paths and parallel branches to perform independent work concurrently. Bound concurrency and define join behavior to protect downstream capacity and handle partial failures.
6. **Execution visibility**: Record execution identifiers, transitions, task outcomes, and failure details to diagnose stalled or failed processes. Select logging and history retention deliberately, and avoid exposing sensitive workflow data.

## Cloud services for State Machines

AWS Step Functions, Azure Durable Functions, and Google Cloud Workflows are alternative orchestration services for coordinating distributed processes. They manage workflow progression, while compute services and APIs perform the actual business operations. In an AWS design, Step Functions can invoke Lambda functions for validation or transformation and coordinate other supported service integrations without placing all sequencing logic inside a function. Queues can buffer work when workers need independent scaling, and callbacks can report completion when the integration supports them. Across platforms, verify persistence and retry semantics, apply least-privilege permissions, propagate execution identifiers, and make side-effecting operations idempotent.

- **[AWS Step Functions](https://blowstack.com/tools/cloud-services-hub/aws-step-functions)**: Executes state-machine workflows that coordinate AWS services and external work using tasks, choices, waits, and parallel processing. Standard and Express Workflows have different duration limits, execution semantics, and observability characteristics, so workflow type must match the workload.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: Runs task implementations invoked by an orchestrator such as AWS Step Functions. Keeping functions focused on individual operations separates business processing from workflow coordination; functions should handle possible repeated invocation safely.

## State Machines exam questions

Real practice exam questions on State Machines, with the correct answer and its explanation.

### Question 1 (SAA-C03)

**Question:**

A software company provisions customer environments by using separate AWS Lambda functions to create a workspace, activate the customer's account, and delete a workspace. Account activation requires the workspace ID returned by the creation function. If activation returns a nonretryable error, the company must delete the newly created workspace before recording the provisioning workflow as failed. The functions must remain independently deployable, and coordination logic must not be added to them. Which solution meets these requirements with the least custom code?

**Correct answer:** Create an AWS Step Functions Standard workflow that creates the workspace and then activates the account. Add a Catch handler to the activation task that preserves the workspace ID and transitions to the deletion task. Transition to a Fail state after deletion succeeds.

**Explanation:** The state machine explicitly coordinates the tasks and defines a compensation path. The Catch handler routes activation errors to workspace deletion while retaining the identifier needed for cleanup. The workflow reaches the Fail state only after deletion succeeds, without adding coordination logic to the Lambda functions.

## Practice State Machines in a full exam

Questions on State Machines in each practice exam, with every answer option and an explanation for each:

- [SAA-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate): 3 questions

## What is State Machines

A state machine describes a process through states, transitions, and the conditions or events that trigger those transitions. An execution starts in an initial state, progresses according to defined rules, and may reach a successful or failed terminal state. States can represent business conditions, such as awaiting payment, or workflow operations, such as invoking a service, waiting for a callback, or choosing the next branch. The model defines which transitions are valid instead of allowing arbitrary changes to process status.

In cloud systems, a workflow orchestrator can execute this model across independently deployed services. The orchestrator tracks progress and decides what should happen next, while workers perform business operations. For example, an order workflow might validate a request, reserve inventory, authorize payment, and request shipment. A payment rejection takes a different path from a temporary payment-service timeout. Separating coordination from task implementation avoids embedding the entire workflow in one function or distributing its sequencing logic across many services.

Durable orchestration is especially useful when a process must survive worker failures or wait for external events. A document-processing workflow might submit a batch job, wait for completion, request human approval, and then publish the result. A suitable orchestration engine persists enough execution information to continue without keeping one application process running throughout the wait. Persistence, execution duration, callback support, and recovery guarantees depend on the engine and workflow type; they are not automatic properties of every state-machine implementation.

Resilience requires explicit failure paths. Retry transient failures with bounded attempts and backoff, set task and workflow timeouts, and route unrecoverable errors to handling or compensation states. If inventory reservation succeeds but payment ultimately fails, a compensating operation can release the reservation. This is not an automatic database rollback: each service owns its data, and compensation is another business operation that can itself fail and require recovery.

Retries and durable execution do not guarantee exactly-once business effects. A worker might complete a payment operation before its response is lost, causing a retry to repeat the request. Use idempotency keys, deduplication records, or conditional updates to prevent duplicate effects. Keep execution data bounded, pass references to large objects rather than embedding them, and limit parallelism so a scalable orchestrator does not overwhelm downstream APIs or databases.

Orchestration and messaging solve different problems. A queue buffers work and decouples producers from consumers, but it does not by itself define a multi-step process with branching, joins, and compensation. Event-driven choreography lets services react independently to events; orchestration makes the overall sequence explicit. They can be combined, with a state machine dispatching queued work and waiting for completion signals.

For architecture questions, choose workflow orchestration when requirements emphasize ordered tasks, conditional branches, parallel work, callbacks, and centralized failure handling. AWS Step Functions is one implementation, not the definition of the concept. Evaluate execution semantics, service quotas, transition or execution costs, observability, and provider coupling. A state machine improves coordination, but it does not remove downstream capacity limits or make a distributed workflow a single atomic transaction.

## Learn State Machines in lessons

1 short lesson on State Machines in 1 certification course.

- SAA-C03: State Machines: coordinating distributed workflows (Premium), https://app.blowstack.com/lessons/state-machines-coordinating-distributed-workflows-saa-c03
