AWS Step Functions: Orchestrating Serverless Workflows

AWS Step Functions coordinates other services into a workflow with retries, branching and a visible history. This guide explains state machines and state types, the three integration patterns, error handling, Standard versus Express workflows, billing, and a nightly data pipeline written in Amazon States Language.

GloryTecks Team

Training & Placement Faculty

6 May 2026 7 min read

Last updated: 1 October 2026

Share:

A data pipeline is rarely one job. It is a job, then a check, then a load, with a notification if anything breaks, and a rule about what to retry. Written as code inside a Lambda function, that logic becomes a tangle of waits and try blocks, and nobody can see where a run stopped.

The service takes the coordination out of your code. You describe the workflow as a state machine; Step Functions runs it, waits for each step, retries failures, and records what happened. AWS lists creating data and machine learning pipelines among its main uses (Step Functions docs: what is Step Functions).

The vocabulary

  • State machine, or workflow: the definition, a series of steps.
  • State: one step. Each has a type and names the state that follows it.
  • Execution: one run of the workflow, with its own input, history and outcome.
  • Amazon States Language (ASL): the JSON format in which workflows are written.

Workflows can be drawn in the console's Workflow Studio or written as JSON. Either way the result is an ASL document, which belongs in version control.

The states

A Task state does work: it calls another AWS service. The other seven are flow states that direct the workflow (Step Functions docs: workflow states):

StatePurpose
TaskCall a service: run a Glue job, invoke a Lambda function, start a query
ChoiceBranch on a condition
ParallelRun fixed branches at the same time
MapRun the same steps for each item in a list
WaitPause for a duration or until a time
PassPass input through, or inject fixed data
Succeed, FailEnd the execution with success or failure

Map deserves a note for data work. It runs the same steps for every item in a dataset, in parallel, and the input can be a JSON array, a list of S3 objects or a CSV file (Step Functions docs: Map state). "Process each of these 200 files" is one Map state.

How a task talks to a service

More than two hundred AWS services can be called from a task. What matters is the integration pattern, which decides when the workflow moves on (Step Functions docs: integration patterns):

PatternBehaviourTypical use
Request ResponseCall the service, continue as soon as it answersPublish a message, start something you will not wait for
Run a Job (.sync)Call the service and wait until the job completesGlue jobs, Athena queries, EMR steps, ECS tasks
Wait for CallbackPause until a task token is returnedHuman approval, work done by an external system

The second pattern is why the service suits pipelines. Starting a Glue job returns immediately, long before the job finishes. With .sync, the workflow waits for the real outcome and proceeds, or fails, accordingly. You write no polling loop.

A pipeline in ASL

The definition below runs a Glue job, then an Athena query against its output, and sends a notification if either fails. It is written from the documentation and has not been deployed.

json
{
  "Comment": "Nightly trips pipeline",
  "QueryLanguage": "JSONata",
  "StartAt": "TransformTrips",
  "States": {
    "TransformTrips": {
      "Type": "Task",
      "Resource": "arn:aws:states:::glue:startJobRun.sync",
      "Arguments": { "JobName": "trips-to-curated" },
      "Retry": [
        { "ErrorEquals": ["States.TaskFailed"], "IntervalSeconds": 60, "MaxAttempts": 2, "BackoffRate": 2.0 }
      ],
      "Catch": [
        { "ErrorEquals": ["States.ALL"], "Next": "NotifyFailure" }
      ],
      "Next": "CheckRowCount"
    },
    "CheckRowCount": {
      "Type": "Task",
      "Resource": "arn:aws:states:::athena:startQueryExecution.sync",
      "Arguments": {
        "QueryString": "SELECT count(*) FROM lake.daily_borough WHERE pickup_date = current_date - interval '1' day",
        "WorkGroup": "pipelines"
      },
      "Catch": [
        { "ErrorEquals": ["States.ALL"], "Next": "NotifyFailure" }
      ],
      "End": true
    },
    "NotifyFailure": {
      "Type": "Task",
      "Resource": "arn:aws:states:::sns:publish",
      "Arguments": {
        "TopicArn": "arn:aws:sns:us-east-1:123456789012:pipeline-alerts",
        "Message": "Nightly trips pipeline failed"
      },
      "Next": "Failed"
    },
    "Failed": { "Type": "Fail", "Error": "PipelineFailed" }
  }
}

Reading it top to bottom:

  • The first task starts the Glue job and waits for it. If the task fails, it is retried twice, after 60 and then 120 seconds.
  • Its catch block sends any error that survives the retries to NotifyFailure instead of ending the execution at that point.
  • The second task runs an Athena query and waits for it, a simple check on the job's output.
  • The failure branch publishes to an SNS topic, then moves to a Fail state so the execution is recorded as failed.

Without the catch block, the behaviour is the default the guide describes: when a state reports an error, the entire execution fails.

Retries and catches

Error handling is the main reason to use an orchestrator, so the fields are worth knowing (Step Functions docs: error handling):

FieldMeaningDefault
ErrorEqualsWhich error names this rule matchesRequired
IntervalSecondsWait before the first retry1
MaxAttemptsMaximum retries3
BackoffRateMultiplier applied to the interval after each attempt2.0

Two cautions. Retrying is only safe when the task is idempotent: a Glue job that appends rows will append them again. And retry transient errors, not everything; a job that fails because of bad data will fail again on every retry and delay the alert. Idempotency in data pipelines explains how to make a step safe to repeat.

Standard or Express

You choose a type when creating the workflow, and it cannot be changed afterwards (Step Functions docs: choosing workflow type).

StandardExpress
Maximum durationOne yearFive minutes
Execution modelExactly-onceAt-least-once
Billed byState transitionsExecutions, duration and memory
Integration patternsAll threeRequest Response only
SuitsBatch pipelines, long jobs, approvalsHigh-volume, short event processing

Data pipelines are almost always Standard: jobs run longer than five minutes, need the .sync pattern, and benefit from the stored execution history.

What it costs

Standard workflows are charged by state transition, counted each time a step is executed, retries included, with 4,000 free transitions a month (AWS: Step Functions pricing). A nightly pipeline of a dozen steps is a few hundred transitions a month. The pattern to watch is a loop: a workflow that polls every few seconds, or a Map over millions of items in a Standard workflow, generates transitions quickly. The services the workflow calls are billed separately.

Where it fits in a data platform

This is a general orchestrator for AWS services. It is strong when a pipeline spans several of them, Lambda, Glue, Athena, EMR, ECS, and when event-driven starts and per-step retries matter. It is less convenient for hundreds of interdependent tables with backfills and data-aware scheduling, where a tool built for data pipelines fits better; the Airflow tutorial shows that model, and Glue workflows vs Step Functions compares it with Glue's built-in option.

A common arrangement: an S3 event or a schedule in EventBridge starts the state machine; small checks run as Lambda functions; heavy work runs as Glue or EMR tasks. Event-driven pipelines with Lambda and S3 covers the trigger.

Good practice

  • Keep business logic out of the state machine. It coordinates; jobs and functions compute.
  • Pass references, not data. Hand S3 paths between states, not file contents.
  • Give every task a timeout, so a hung job does not hold an execution open.
  • Catch at the task, notify, then fail, so failures are both reported and recorded.
  • Name states for what they do. The names are what you read in the execution history at 3 am.

What is AWS Step Functions used for?

Coordinating several AWS services into a workflow with ordering, branching, retries and error handling, for example a multi-step data pipeline.

What is the difference between Step Functions and Lambda?

Lambda runs a piece of code. Step Functions decides which pieces of work run, in what order, and what happens on failure.

What is Amazon States Language?

The JSON-based language in which workflows are defined: states, their types, transitions and error handling.

Should I use Standard or Express workflows for ETL?

Standard, in most cases. It supports jobs that run for a long time and the pattern that waits for a job to finish.

Workflow orchestration and AWS data services are covered in the Data Engineering course.

Sources

GloryTecks Team

Training & Placement Faculty

The GloryTecks faculty team mentors learners across Data Science, AI and Data Engineering, with a focus on real-time projects and placement readiness in Hyderabad.

Want to master AWS?

Join GloryTecks’ expert-led Data Engineering training in Hyderabad with real-time projects and 100% placement support.

Explore course