CertificationTestPrep Free diagnostic

AWS · explainer · checked November 4, 2026

AWS Step Functions vs Lambda: when a workflow belongs in a state machine

They are not alternatives. AWS Lambda runs your code in response to an event. AWS Step Functions runs a workflow, called a state machine, that decides which step happens next and handles retries, errors and waiting. A step is often a Lambda function, so the two are usually used together. Put the ordering and error handling in Step Functions, and the business logic in Lambda.

Side by side

AWS LambdaAWS Step Functions (Standard)AWS Step Functions (Express)
What it runsA function you write, in a supported runtimeA workflow of states, defined in Amazon States LanguageThe same kind of workflow, tuned for high event rates
Longest run15 minutes per invocation by defaultOne yearFive minutes
Execution guaranteeEvent source mappings process each event at least once, so AWS advises idempotent codeExactly-once workflow executionAt-least-once (asynchronous) or at-most-once (synchronous)
Execution historyCloudWatch logs and metricsKept by Step Functions for up to 90 days after the run endsNot kept by Step Functions; send it to CloudWatch Logs
How you payPer request plus GB-seconds of run timePer state transitionPer execution, its duration and memory
Waits for a job or a callbackNot a feature of a single functionYes, for supported services (.sync and .waitForTaskToken patterns)No, request-response only

What each one does

AWS Lambda is a serverless compute service. You write a handler function, connect it to a trigger such as Amazon API Gateway, Amazon S3, Amazon SQS or Amazon EventBridge, and Lambda runs it without you managing servers. One invocation does one piece of work and, by default, can run for up to 15 minutes.

AWS Step Functions is a workflow service. You describe a state machine: a series of steps, each called a state. A Task state does a unit of work, usually by calling another AWS service. A Choice state branches on the data, a Parallel state runs branches at the same time, and a Map state runs the same steps for every item in a list. Each running copy of a workflow is called an execution, and the console shows a visual graph of what each step did.

They are usually used together

The most common Task state invokes a Lambda function. Lambda does the work of the step, and Step Functions decides what comes before and after it. Step Functions treats an exception inside the function as a failed task, and the workflow then follows its error rules.

Step Functions can also call over two hundred AWS services directly through AWS SDK integrations, so a step does not always need a function. Writing a Lambda function whose only job is to call another AWS API is code you may not need to own.

When the workflow belongs in a state machine

Choose Step Functions when the problem is the flow, not the computation:

  • **Several steps in a fixed order.** The state machine records where each execution is, instead of your code passing state from function to function.
  • **Retries and fallbacks.** A Retry field on a state sets the interval, the maximum attempts (3 by default) and the backoff rate (2.0 by default). A Catch field sends the workflow to a fallback state. Steps retried this way are billed as state transitions.
  • **Waiting.** A workflow can wait for a job to finish or for a callback with a task token, for example a human approval. A Lambda invocation that sat waiting would be limited by its run time.
  • **Branching and fan-out.** Choice, Parallel and Map states express this without loops in your code.
  • **Auditing.** A Standard workflow shows each step of each execution.

As a rule of thumb, keep the logic in Lambda when it is one short task: resize an image, validate a request, transform a record. A single function triggered by an event needs no workflow around it. The Lambda best-practices page also warns against recursive invocations, where a function triggers itself, because of the cost of runaway invocation volume.

Standard or Express workflows

You choose the workflow type when you create the state machine, and you cannot change it afterwards.

**Standard** workflows run for up to one year and follow an exactly-once model: tasks and states are not run more than once unless you wrote Retry behavior. That suits actions that are not safe to repeat, such as starting an Amazon EMR cluster or processing a payment. Step Functions keeps the execution history, and you can retrieve it for up to 90 days after the run completes.

**Express** workflows run for up to five minutes and are meant for high-volume work such as streaming data processing, IoT ingestion and mobile backends. Asynchronous Express workflows run at least once, so a step may run twice, which suits idempotent actions such as writing the same item to Amazon DynamoDB. Synchronous Express workflows run at most once and return the result to the caller. Express workflows do not keep history in Step Functions, so you turn on logging to CloudWatch Logs, and they do not support the job-run (.sync) or callback (.waitForTaskToken) patterns.

Billing differs too. Standard is priced by state transitions, Express by executions, duration and memory. Check the Step Functions pricing page for current rates.

A newer option: Lambda durable functions

Lambda also offers durable functions, which let one function run a multi-step process in ordinary code for up to a year. It checkpoints progress, retries steps, and can suspend during a wait without compute charges. AWS describes the difference as where each runs and how you define the workflow: durable functions live inside Lambda and use a programming language, while Step Functions is a separate service with a visual designer, integrations with 220-plus services and no runtime to maintain. AWS suggests durable functions when the logic is mostly inside Lambda, Step Functions when many AWS services are involved, and notes that many applications use both.

On the exams

How certification exams use this

The exam guides ask candidates to choose workflow orchestration (SAA-C03 knowledge item 2.1.k16), to design multi-step workflows with durable execution patterns using Step Functions or durable Lambda functions (SAP-C03 task 1.1.4), and to write Lambda automations for complex scenarios using Step Functions (DOP-C02 task 2.3.s2). SCS-C03 task 2.1.4 lists Step Functions among the ways to remediate incidents automatically, and AIP-C01 tasks 1.2.3 and 1.6.2 use Step Functions in generative AI designs. DVA-C03 names Step Functions as an in-scope service. Watch for the cue words: a long wait, human approval or per-step retries point at a state machine, while one short event-driven task points at a function alone. The usual wrong answer is chaining functions that call each other.

Test yourself

See how well you know it, free.

Each exam’s diagnostic is free, with no sign-in: questions across the whole exam, and a map of what you know and what you don’t.