VAYULearn
Colour theme
Investigate a failure
VAYU Learn

AWS Data Engineering

AWS Step Functions for Data Pipeline Orchestration

DataForge AWS Data Engineering Series - Blog 11 of 20

AWS Data EngineeringAirflow & Orchestration

The pipeline had five steps: ingest, validate, transform, load, notify. It was built as five Lambda functions, each one invoking the next directly in code - ingest calls validate, validate calls transform, and so on. It worked, until the transform step started failing intermittently under load, and nobody could answer a simple question: which step failed, on which run, and did the ones before it actually complete?

There was no execution history. No visual trace. Just five separate sets of CloudWatch Logs, and a debugging session that involved manually correlating timestamps across five different log groups to reconstruct what had actually happened during one failed run — repeated every time a similar failure occurred, because nothing about the architecture retained the relationship between the steps.

The fix wasn’t better logging. It was recognizing that “five Lambda functions calling each other directly” is not orchestration — it’s a hidden dependency chain with no execution record, no retry semantics beyond whatever each function implements independently, and no way to see the pipeline’s actual state at any point in time. Step Functions exists specifically to replace that pattern with something that has all three.

Let’s go deep.


TL;DR

Step Functions defines pipelines as explicit state machines — sequences of states with defined transitions, built-in retry and error handling, branching logic, and parallel execution — rather than services calling each other directly with no shared execution record. For AWS-native data pipelines assembling Glue, Lambda, EMR, and other services into multi-step workflows, Step Functions provides visual execution history, granular error handling, and orchestration primitives that ad hoc service-to-service invocation cannot replicate.

By the end of this article you’ll be able to:

  • Design a state machine with correct retry, catch, and branching logic for a real data pipeline
  • Use the Map state to process collections of files in parallel with controlled concurrency
  • Understand exactly when Step Functions is the right orchestration choice versus Airflow or Glue Workflows
  • Diagnose state machine failures using execution history instead of correlating logs across services

Series context: This is where Blog 5 (Glue), Blog 10 (Lambda), and the compute services from Blogs 6–9 get assembled into actual multi-step pipelines. Blog 16 builds a complete event-driven pipeline using the patterns from this article.

Five Lambdas calling each other directly: five log groups, zero execution record, manual correlation after every failure. A state machine: one execution history, every retry and branch visible, in one place.

Why “Services Calling Each Other” Isn’t Orchestration

Before Step Functions specifics, it’s worth being precise about what problem it solves, because the alternative (direct service-to-service invocation) looks like it works until it doesn’t.

Direct invocation pattern (the opening scenario):
Lambda A --invokes--> Lambda B --invokes--> Lambda C
Problems this creates:
No unified execution record - each function's
logs are independent, correlated only by manual
timestamp matching
Retry logic must be reimplemented in every
function independently, inconsistently
No visibility into "where is this pipeline run
right now" without checking multiple services
Error handling logic is scattered - each function
decides what happens on its own failure, with no
coordinated view of the whole pipeline's state
Timeout chains: if A calls B synchronously and
waits, A's own timeout now depends on B's runtime,
compounding Lambda's 15-minute ceiling (Blog 10)
across multiple hops
Step Functions pattern:
State Machine: [Ingest] -> [Validate] -> [Transform]
-> [Load] -> [Notify]
What this provides:
One execution record per pipeline run, showing
every state's input, output, duration, and status
Retry and Catch defined declaratively per state,
consistent and visible
Visual execution graph - see exactly where a run
is, or where it failed, without correlating logs
Each state invokes its target service
asynchronously in most patterns, avoiding the
Lambda timeout-chaining problem

The structural difference that matters most: Step Functions maintains state about the pipeline itself, separate from any individual service’s own state. This is the same architectural principle as the Databricks series’ Lakeflow Jobs DAG — the orchestrator’s job is to know what happened, not just to make things happen.


State Machine Anatomy: The Building Blocks

Step Functions state machines are defined in Amazon States Language (ASL), a JSON-based specification. A handful of state types cover the vast majority of data pipeline patterns.

{
"Comment": "Daily ETL pipeline",
"StartAt": "ValidateInput",
"States": {
"ValidateInput": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123:function:validate",
"Retry": [
{
"ErrorEquals": ["States.TaskFailed"],
"IntervalSeconds": 30,
"MaxAttempts": 3,
"BackoffRate": 2.0
}
],
"Catch": [
{
"ErrorEquals": ["ValidationError"],
"Next": "NotifyValidationFailure"
}
],
"Next": "TransformData"
},
"TransformData": {
"Type": "Task",
"Resource": "arn:aws:states:::glue:startJobRun.sync",
"Parameters": {
"JobName": "silver-transform"
},
"Next": "LoadToRedshift"
},
"LoadToRedshift": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "redshift-copy-trigger"
},
"Next": "NotifySuccess"
},
"NotifySuccess": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"End": true
},
"NotifyValidationFailure": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"End": true
}
}
}

The state types data engineering pipelines actually use:

Task:      Invokes a Lambda, Glue job, ECS task, or other
supported AWS service action
Choice: Branches based on a condition (data quality
check pass/fail, file type routing)
Parallel: Runs multiple fixed branches simultaneously
Map: Runs the SAME processing logic over a
collection of items concurrently (covered
in depth below)
Wait: Pauses for a specified duration or until a
timestamp
Pass: Passes input to output, optionally
transforming it - useful for data shaping
between states

How Retry and Catch Actually Work: The Mechanism

This is the mechanism worth understanding precisely, because the distinction between Retry and Catch is exactly the distinction between transient and permanent failures covered in the Databricks series’ Lakeflow Jobs article — applied here at the orchestration layer instead of the job layer.

Retry: handles TRANSIENT failures - the same operation
run again might succeed
(network blip, temporary service throttling,
a Glue job that occasionally times out under
unusual load)
Catch: handles the failure PERMANENTLY - retries are
exhausted or the error type isn't retryable,
and now the state machine needs to DO something
different (alert, compensating action, graceful
stop) rather than trying the same thing again
Execution walkthrough:
ValidateInput state executes
|
v
Task fails with States.TaskFailed
|
v
Retry policy checks: has MaxAttempts (3) been
reached? No - wait IntervalSeconds (30s) x
BackoffRate, retry
|
v
Retry attempt 2: fails again
|
v
Retry attempt 3: fails again
|
v
MaxAttempts reached - Retry policy exhausted
|
v
Catch policy checks: does the error match
ErrorEquals ("ValidationError")?
|
+-- YES -> transition to NotifyValidationFailure
| state (defined recovery path)
|
+-- NO (unmatched error type) -> state machine
execution FAILS entirely, visible in
execution history as a failed run

The exam-equivalent trap this mirrors from the Databricks series: just as retries don’t fix logic errors in Lakeflow Jobs, Step Functions retries don’t fix a Glue job that’s failing because of a code bug — retrying the same broken code three times produces the same failure three times, consuming time and Retry budget without changing the outcome. Retry is for infrastructure-level transient failures; Catch (routing to a different path) is for everything else, including permanent logic failures that need human intervention or a different automated response.


The Map State: Parallel Processing at the Orchestration Layer

The Map state runs the same set of steps over every item in a collection, with configurable concurrency — the orchestration-level equivalent of a parallelized loop.

{
"ProcessAllFiles": {
"Type": "Map",
"ItemsPath": "$.fileList",
"MaxConcurrency": 5,
"Iterator": {
"StartAt": "ProcessSingleFile",
"States": {
"ProcessSingleFile": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123:function:process-file",
"End": true
}
}
},
"Next": "AllFilesComplete"
}
}

How this differs from simply invoking Lambda concurrently yourself: the Map state provides per-item execution tracking within the parent execution’s history — you can see exactly which items in the collection succeeded, which failed, and retry logic applies per-item, not just to the Map state as a whole. MaxConcurrency controls how many iterations run simultaneously, directly analogous to the for_each task concurrency setting covered in the Databricks series' Lakeflow Jobs article — and it exists for the identical reason: unconstrained concurrency can overwhelm downstream resources (Lambda concurrency limits, database connections, API rate limits) that weren't designed for every item to hit simultaneously.

Distributed Map, a newer variant, scales to processing up to 10,000 items per Map state (versus the standard Map’s lower practical limits) and reads its item list directly from S3 — the correct choice when the “collection to iterate over” is itself a large list of files in an S3 prefix rather than a small array passed in the execution input.


Step Functions vs Airflow: The AWS-Native Decision

Both orchestrate multi-step pipelines. The decision isn’t about which is “better” in the abstract — it’s about which fits the actual operating environment.

Choose Step Functions when:
Pipeline is composed primarily of AWS service calls
(Glue, Lambda, ECS, SNS, DynamoDB)
Team wants zero orchestration infrastructure to
manage (no Airflow scheduler/webserver/workers
to run)
Visual execution history and built-in AWS IAM
integration (Blog 3's model, applied to
orchestration permissions) are valued
Pipeline complexity is moderate - sequential and
parallel steps, branching, without needing Airflow's
extensive plugin ecosystem
Choose Airflow (self-managed or Amazon MWAA) when:
Pipeline needs to orchestrate across multiple
clouds or on-premises systems, not just AWS services
Team has existing Airflow DAGs and operational
expertise
Complex dependency graphs benefit from Airflow's
Python-native DAG definition versus Step Functions'
JSON-based ASL
Need Airflow's extensive provider ecosystem for
non-AWS integrations

The honest trade-off often overlooked: Step Functions has no separate infrastructure to run — no scheduler process, no worker nodes, nothing to patch or scale. Airflow (even managed via MWAA) has an underlying execution environment that needs sizing and monitoring, similar to the operational overhead trade-offs covered throughout Blog 7’s Glue/EMR/Athena comparison. For AWS-native pipelines without a pre-existing Airflow investment, Step Functions’ zero-infrastructure model is a genuine, not just marginal, operational advantage.


Standard vs Express Workflows: The Cost and Duration Trade-off

Step Functions offers two workflow types with meaningfully different cost models and duration limits.

Standard Workflows:
Maximum duration: 1 year
Exactly-once execution semantics
Full execution history retained and visible
Pricing: per state transition
Correct for: most batch data pipelines, long-running
workflows, anything needing durable execution history
Express Workflows:
Maximum duration: 5 minutes
At-least-once execution semantics (can execute a
state more than once in rare failure scenarios)
Execution history goes to CloudWatch Logs (not the
same rich visual history as Standard)
Pricing: per execution + duration + memory,
optimized for very high-volume, short-duration
executions
Correct for: high-volume, short-duration event
processing (e.g., a state machine invoked per
Kinesis record at massive scale)

The decision this maps to directly: if your pipeline resembles the Lambda-and-Glue orchestration patterns covered throughout this series — periodic, multi-step, benefiting from durable execution history — Standard Workflows is correct. If you’re orchestrating extremely high-frequency, short-lived executions (processing individual stream records at very large scale where per-execution cost matters enormously), Express Workflows’ different cost model becomes relevant, at the cost of weaker execution guarantees.


Architecture Flow: A Complete Step Functions Pipeline

EventBridge (S3 event or schedule)
|
v
+---------------------------------------------------+
| Step Functions State Machine (Standard) |
| |
| [ValidateInput] --Task--> Lambda |
| | Retry: transient failures |
| | Catch: ValidationError -> alert path |
| v |
| [Choice: file type?] |
| +-- CSV -> [TransformCSV] -> Glue Job |
| +-- Parquet -> [TransformParquet] -> Glue |
| | |
| v |
| [ProcessAllPartitions] --Map, MaxConcurrency:5-- |
| | (parallel per-partition processing) |
| v |
| [LoadToRedshift] --Task--> Lambda (COPY trigger) |
| | |
| v |
| [NotifySuccess] --Task--> SNS |
+---------------------------------------------------+
|
v
Full execution history: every state's input,
output, duration, retry attempts - visible in
one place, no log correlation required

Failure Modes You’ll See in Production

Direct service-to-service invocation with no orchestration layer. The opening scenario. Multiple Lambda functions or Glue jobs call each other directly with no shared execution record. Debugging a failure requires manually correlating logs across services, and there’s no single place to see “where is this pipeline run right now.”

Retry configured for a permanent failure, wasting time before finally catching it. A Glue job fails due to a code bug (a genuine logic error, not a transient issue). The state’s Retry policy attempts it 3 times with exponential backoff, consuming 5+ minutes before finally exhausting retries and reaching the Catch block — the same “retries don’t fix logic errors” trap from the Databricks series, here costing wall-clock time on every failed pipeline run instead of catching the error immediately.

Map state with unbounded concurrency overwhelming a downstream resource. A Map state processes 200 files with no MaxConcurrency limit set, launching 200 simultaneous Lambda invocations that all attempt to write to the same downstream database, exceeding its connection pool limit and causing cascading failures across what should have been 200 independent, successful operations.

Express Workflow used for a pipeline that needed Standard’s durability guarantees. A team chooses Express Workflows for cost optimization on a batch ETL pipeline, not realizing the at-least-once semantics mean a state could theoretically execute more than once under rare failure conditions — fine for idempotent operations, but a genuine correctness risk for a non-idempotent step (like triggering a non-idempotent downstream charge or notification) that assumed Standard’s exactly-once guarantee.

IAM role for the state machine missing permission for one of several orchestrated services. Following directly from Blog 3’s lesson, a state machine’s execution role is granted permission to invoke Glue and Lambda, but the SNS notification step’s permission (sns:Publish) is overlooked. The pipeline runs successfully through every data processing step and then fails at the final notification state — the entire ETL workload completes correctly, but the pipeline reports failure because of one missed IAM grant on the least data-critical step.

Choice state logic with an unhandled default case. A Choice state branches on file type (CSV, Parquet, JSON) but doesn’t define a Default transition for an unexpected file type. A file with an unanticipated extension arrives, and the state machine execution fails with a generic "no matching rule" error rather than routing to an explicit error-handling or alert path.


Trade-offs: What Step Functions Optimizes For

Step Functions optimizes for:

  • Zero orchestration infrastructure — no scheduler or worker nodes to manage
  • Native AWS service integration with direct API actions (not custom code wrappers) for many services
  • Visual, per-execution history that makes debugging a specific pipeline run tractable
  • Granular, declarative retry and error handling per state

Step Functions doesn’t optimize for:

  • Non-AWS orchestration — cross-cloud or on-premises coordination is awkward compared to Airflow’s broader ecosystem
  • Complex, deeply nested conditional logic — very intricate branching can become difficult to reason about in ASL’s JSON structure compared to Python-native DAG definitions
  • Long-lived stateful workflows requiring human-in-the-loop patterns beyond the built-in waitForTaskToken pattern (which does support this, but with its own learning curve)
  • Cost predictability at very high state-transition volumes without careful Standard vs Express selection

The honest trade-off: Step Functions trades some of Airflow’s flexibility and ecosystem breadth for zero infrastructure overhead and tight AWS-native integration. For pipelines that are fundamentally “orchestrate AWS services,” this trade strongly favors Step Functions. For pipelines with significant non-AWS components or teams with deep existing Airflow investment, the calculation shifts.


Real-World Constraints

Execution history retention limits. Standard Workflow execution history is retained for 90 days. Pipelines needing longer audit trails must export execution data to CloudWatch Logs or S3 explicitly — the built-in history isn’t a permanent audit log by default.

State input/output size limits. Data passed between states (not the data being processed, but the JSON payload passed through the state machine itself) is limited to 256KB. Pipelines processing large file lists or large intermediate results need to pass references (S3 paths, database keys) between states rather than the actual data — the same principle as passing table names rather than DataFrames between Lakeflow Job tasks in the Databricks series.

Nested state machine depth and complexity limits. Very complex pipelines with deeply nested Parallel and Map states can become difficult to visualize and debug even with Step Functions’ visual tooling. Breaking an overly complex single state machine into multiple state machines invoked via startExecution (nested workflows) is often cleaner than one enormous monolithic definition.


What This Means for the Rest of the Series

Blog 15 (Real-time pipeline architecture) and
Blog 16 (Event-driven ETL pattern): both assemble
Step Functions
state machines
from the building
blocks in this
article, connecting
Kinesis/S3 triggers
(Blogs 8, 10) to
Glue transformations
(Blog 5) and Redshift
loads (Blog 6)

Summary: The Engineering Lesson

Orchestration isn’t a nice-to-have layered on top of a working pipeline — it’s the difference between a pipeline you can reason about and one you can only guess at when something goes wrong. Direct service-to-service invocation looks like orchestration because the pipeline runs successfully most of the time, but it has no execution record, no unified retry semantics, and no visibility into partial failure — exactly the debugging nightmare the opening scenario describes.

Step Functions’ value isn’t that it makes services do anything they couldn’t do before. It’s that it makes the pipeline’s execution — every state, every retry, every branch taken — a first-class, queryable thing, rather than an implicit relationship buried in code that calls other code.

The question worth asking about any multi-step AWS data pipeline: if step three failed on last night’s run, could you answer “what was the state of steps one and two at that moment” without manually correlating logs across services? If not, that pipeline needs Step Functions, not better logging.


Next in Series

Blog 12 - Amazon Athena: SQL on S3 Without Servers

Blog 7 introduced Athena as part of the compute decision framework. This article goes deep specifically on Athena — the partitioning strategies, workgroup configuration for cost control, and the specific SQL patterns that determine whether a query costs pennies or dollars against the same underlying data.

We’ll go deep on Athena’s relationship to the Glue Data Catalog, federated queries across multiple data sources, and the concrete techniques that make Athena the highest-leverage cost optimization opportunity in most AWS data platforms.


Comment Below

What’s the most painful debugging session you’ve had with a pipeline that had no real orchestration layer — just services calling each other directly?

Was it correlating timestamps across five different CloudWatch Log groups to reconstruct what happened during one failed run? A retry loop implemented inconsistently across different Lambda functions, each handling failure differently? A pipeline where nobody could answer “is this still running or did it die silently three hours ago” without manually checking each service?

And — did moving to explicit orchestration (Step Functions, Airflow, or otherwise) actually fix it, or just make the same underlying problems easier to see?


Tags: aws-data-engineering, step-functions, orchestration, state-machine, workflow-automation, aws-glue, error-handling, dataforge