Orchestrating Pipelines with AWS Step Functions
This lesson explains how AWS Step Functions, the serverless orchestrator for pipelines that span many AWS services, runs steps in the right order, handles errors and retries, and shows what happened.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the state types of a state machine.
- Distinguish request response, run a job and wait for callback integration patterns.
- Handle errors with Retry and Catch and choose a workflow type.
- Choose between Step Functions, Glue workflows and MWAA.
States
A Step Functions state machine is a workflow built from states. A Task state does the work by calling a service, such as starting a Glue job or invoking a Lambda function. A Choice state branches on the data, for example skipping a load when a file is empty. A Parallel state runs several branches at the same time and waits for all of them, and a Wait state pauses for a period or until a time.
A Map state runs the same steps for each item in a list. Its Distributed Map mode runs up to thousands of child workflows in parallel and can take its items directly from S3, so it can process millions of objects or the rows of a large CSV file. The following table summarises the state types.
| State | Purpose |
|---|---|
| Task | Calls a service |
| Choice | Branches |
| Parallel | Runs branches at the same time |
| Map | Runs steps for each item; Distributed Map handles millions of S3 objects or CSV rows |
| Wait | Pauses |
Step Functions states
Integration patterns
A Task state can call a service in three ways, and the choice decides whether the workflow waits. With request response, the state calls the service and moves on as soon as the call returns. Starting a Glue job this way only confirms the job started, not that it finished. The .sync pattern, such as glue:startJobRun.sync, starts the job and waits until it completes, failing the state if the job fails. This is what a pipeline usually needs, and it works with EMR, EMR Serverless, Athena, ECS and SageMaker.
Wait for callback pauses the workflow and passes a task token to an external process, such as a person approving a change. The workflow continues only when that process returns the token. The following table summarises the patterns.
| Integration pattern | Behaviour |
|---|---|
| Request response | Calls the service and moves on immediately |
.sync (run a job) | Starts a job and waits for it, for example glue:startJobRun.sync, EMR, EMR Serverless, Athena, ECS, SageMaker |
| Wait for callback | Pauses until a task token is returned, for example for human approval |
The following diagram compares what the workflow waits for with each integration pattern.

Waiting for a job
Error handling and workflow types
Step Functions handles errors declaratively in the workflow definition rather than in code. A Retry field on a state retries it on specified errors, with exponential backoff and a maximum number of attempts, which handles transient failures such as throttling. A Catch field routes errors that persist to another state, such as a clean-up step or a notification, so failures are handled rather than simply ending the workflow.
Step Functions offers two workflow types. Standard workflows run for up to a year, execute each step exactly once and keep a full execution history, which suits long-running data pipelines and processes with human approval. Express workflows run for up to five minutes, handle very high volumes of executions and cost less, which suits short, frequent processing such as handling individual events.
The following diagram shows a nightly Step Functions state machine and its error handling.

Standard or Express?
Which orchestrator
Several services orchestrate pipelines. The following table indicates when each is the appropriate choice.
| Choose | When |
|---|---|
| Step Functions | The pipeline spans many services (Lambda, Glue, EMR, Athena, Redshift Data API, SNS) or needs complex branching and error handling |
| Glue workflows | The pipeline is only Glue crawlers and jobs |
| Amazon MWAA | The team already uses Airflow |
Orchestrating a nightly pipeline
A nightly pipeline must run a crawler, then two Glue jobs in parallel, then a Redshift load, retry transient failures, and alert the team if anything fails. The following table maps each requirement to the Step Functions feature that meets it.
| Requirement | Step Functions feature |
|---|---|
| Wait for each Glue job to finish | glue:startJobRun.sync integration |
| Two jobs at once | Parallel state |
| Retry throttling or transient errors | Retry with backoff on the task |
| Alert on failure | Catch routing to an SNS publish task |
| Run every night at 02:00 | EventBridge Scheduler starting the state machine |
A Glue workflow could orchestrate the Glue parts alone, but the Redshift load and SNS alerts are outside Glue, so Step Functions, which integrates with all of them, is the better orchestrator here.
Which Step Functions feature processes millions of S3 objects in parallel?
Show answer
Distributed Map.
Exam Tips
Remember for the exam
- To run a Glue job and wait for it to complete, use Step Functions with glue:startJobRun.sync.
- To process millions of S3 objects in parallel, use Distributed Map.
- To retry with backoff and route failures, use Retry and Catch.
- A human approval step uses wait for callback with a task token.
- High-volume, short-lived event processing suits Express workflows.