VAYULearn
Colour theme
Investigate a failure
VAYU Learn

AWS Data Engineering

Event-Driven ETL on AWS: S3 Events → Step Functions → Glue

DataForge AWS Data Engineering Series - Blog 16 of 20

AWS Data EngineeringAirflow & OrchestrationData Architecture & Reliability

The nightly batch job ran at 2:00 AM sharp, every night, without fail. It also, on three separate nights over two months, ran against zero new files — because the upstream vendor’s file delivery, which was usually complete by midnight, occasionally slipped to 3 or 4 AM. The job completed successfully each time. It just successfully processed nothing, and the Gold table quietly showed yesterday’s numbers on three mornings before anyone traced the pattern back to vendor delivery timing rather than a pipeline bug.

The fix wasn’t a longer buffer before the scheduled run, and it wasn’t a retry loop hoping files would eventually show up. It was recognizing that the pipeline’s actual requirement was never “run at 2:00 AM” — it was “run when the vendor’s files have arrived,” and those are only the same thing when the vendor is punctual. A scheduled trigger encodes an assumption about timing that data delivery doesn’t actually promise to honor.

This is the AWS-specific version of a pattern the Databricks series covered directly: a pipeline that succeeds at doing the wrong thing — running before data is ready — looks identical to a pipeline that succeeded correctly, right up until someone notices the numbers are stale. This article builds the event-driven alternative: S3 events triggering Step Functions triggering Glue, running exactly when data arrives, not on a clock that assumes it always will.

Let’s go deep.


TL;DR

Event-driven ETL on AWS replaces “run on a schedule and hope data has arrived” with “run when data actually arrives” — S3 object creation events trigger EventBridge rules, which start Step Functions executions that orchestrate the Glue transformation pipeline. This pattern eliminates the entire class of failures where a pipeline runs successfully against incomplete or absent data because the schedule and the data’s actual arrival time drifted apart.

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

  • Configure the complete S3-to-EventBridge-to-Step-Functions trigger chain correctly
  • Handle multi-file batch arrivals without triggering a pipeline run per individual file
  • Distinguish when event-driven triggering is the right pattern versus when a schedule genuinely is sufficient
  • Implement the specific validation that catches a pipeline running against zero or incomplete data, even when the trigger itself worked correctly

Series context: This is the complete assembly of Blog 4 (S3 events), Blog 11 (Step Functions), and Blog 5 (Glue) into one production-ready event-driven pattern — the batch-oriented counterpart to Blog 15’s continuous streaming architecture.

A schedule is an assumption. An event is a fact. The 2 AM job ran on the slow nights anyway: SUCCESS, zero files, stale Gold. Trigger on arrival, debounce with a quiet period, then validate the data before calling the run successful

Why Scheduled Triggers Are the Wrong Default for Most Batch Pipelines

Before the implementation, it’s worth being precise about why this matters, because “just add a buffer to the schedule” is the instinctive but incomplete fix teams usually reach for first.

The scheduled trigger's hidden assumption:
"By 2:00 AM, the data will always have arrived"
What actually determines whether this holds:
Upstream vendor delivery timing (often outside
your control entirely)
Network conditions affecting large file transfers
Upstream system's own batch processing completing
on time
Time zone assumptions that don't account for
daylight saving transitions or regional delivery
variance
The "just add a buffer" instinct and why it doesn't
actually solve the problem:

Moving the schedule to 4:00 AM "to be safe" adds
latency on every night the data WAS ready by
2:00 AM, and STILL fails on the night delivery
slips to 4:30 AM
There is no buffer size that converts a variable
arrival time into a fixed one - it only shifts
the failure threshold and adds unnecessary
latency on every normal night

The structural fix, not a bigger buffer: trigger the pipeline based on the actual signal that data is ready — the file arriving — rather than a time that approximates when it’s usually ready. This is exactly the Databricks series’ file arrival trigger recommendation, implemented here with AWS-native services.


How the Complete Trigger Chain Actually Works: The Mechanism

This is the mechanism worth understanding precisely, because getting the S3-to-EventBridge-to-Step-Functions chain right requires understanding what each link actually does — not just that they can be connected.

Step 1: S3 Event Notification Configuration
S3 bucket configured to emit events on
s3:ObjectCreated:* for a specific prefix
(Blog 4's event notification mechanism)
S3 -> EventBridge (the recommended modern path,
rather than S3 -> SNS/SQS directly, because
EventBridge provides richer filtering and
routing capability)
Step 2: EventBridge Rule
Rule pattern matches on the specific bucket,
prefix, and event type:
{
"source": ["aws.s3"],
"detail-type": ["Object Created"],
"detail": {
"bucket": {"name": ["data-lake-raw"]},
"object": {"key": [{"prefix": "vendor-feed/"}]}
}
}
This rule, when matched, triggers a target -
in this case, starting a Step Functions execution
Step 3: Step Functions Execution Starts
The execution receives the S3 event details
(bucket, key, size - Blog 10's same metadata
available without downloading the file)
The state machine (Blog 11's patterns) can now
make routing decisions, validate the file,
and orchestrate the Glue transformation
Step 4: Glue Job Runs
Triggered as a Step Functions Task state,
with the specific file/prefix passed as a
job parameter - the job processes exactly
the data that triggered it, not "whatever's
in the bucket right now"

The critical architectural decision embedded in Step 4: the Glue job should process the specific file or prefix that triggered the event, not perform a full scan of the entire Bronze location. This keeps each execution’s scope tied to what actually arrived, and it’s what makes the pattern scale — ten files arriving throughout the day trigger ten scoped executions, not ten full-table reprocessing runs.


Handling Multi-File Batch Arrivals Without Triggering Per-File Runs

A common real-world complication: source systems often deliver data as multiple files landing within a short window (a vendor’s export splits into 20 files, all arriving within a few minutes of each other). Triggering a full pipeline execution per individual file is usually wrong — the correct pattern needs to recognize “a batch has arrived” rather than “a file has arrived.”

# Pattern: EventBridge rule triggers a Lambda function
# (Blog 10's correct "decide, don't do" role) that
# implements a debounce/batching check rather than
# triggering Step Functions directly

def lambda_handler(event, context):
bucket = event['detail']['bucket']['name']
key = event['detail']['object']['key']

# Record this file arrival in a tracking table
# (DynamoDB, or a simple S3-based marker file)
record_arrival(bucket, key)

# Check: has enough time passed since the LAST
# file arrival in this batch window to consider
# the batch complete?
last_arrival_time = get_last_arrival_time(bucket, prefix)
if (current_time() - last_arrival_time) > BATCH_QUIET_PERIOD:
# No new files for the quiet period —
# batch is likely complete, start the pipeline
step_functions_client.start_execution(
stateMachineArn=PIPELINE_ARN,
input=json.dumps({"prefix": prefix})
)
else:
# More files may still be arriving — don't
# trigger yet, let a later file's event
# perform this same check
pass

Why this specific pattern rather than a fixed delay: a fixed “wait 5 minutes after the first file” approach fails if the batch genuinely takes longer than 5 minutes some nights and wastes 5 minutes of latency on nights when the batch completes in 30 seconds. The quiet-period pattern (no new file arrivals for N minutes) adapts to actual batch completion timing rather than guessing at a fixed window — directly analogous to the Databricks series’ wait_after_last_change_seconds pattern for file arrival triggers.


Validating That the Pipeline Actually Has Data to Process

Triggering correctly on file arrival solves the “ran before data was ready” problem. It doesn’t automatically solve the related but distinct problem: a pipeline that triggers correctly but still processes an unexpectedly empty or incomplete dataset (a vendor’s file arrived but was truncated, or contained zero rows due to an upstream bug).

{
"ValidateFileNotEmpty": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123:function:validate-file-size",
"Parameters": {
"bucket.$": "$.detail.bucket.name",
"key.$": "$.detail.object.key"
},
"Next": "CheckValidation"
},
"CheckValidation": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.validationResult.rowCount",
"NumericGreaterThan": 0,
"Next": "TransformData"
}
],
"Default": "AlertEmptyFile"
},
"AlertEmptyFile": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"End": true
}
}

This is the exact silent-success prevention pattern from the Databricks series’ Lakeflow Jobs article, implemented with Step Functions Choice states: a file arriving and triggering the pipeline is necessary but not sufficient — the pipeline also needs an explicit check that what arrived contains the data it should, routing to an alert path (rather than silently completing a no-op transformation) when it doesn’t.


When Scheduled Triggers Are Still the Correct Choice

Event-driven triggering isn’t universally superior — Blog 15 and the Databricks series both make this point, and it’s worth restating precisely here rather than treating “event-driven” as an unconditional upgrade.

Scheduled triggers remain correct when:
Data arrival timing is genuinely reliable and
consistent (an internal system with a guaranteed
SLA, not a third-party vendor with variable
delivery)
The pipeline performs a periodic AGGREGATION
over accumulated data (a weekly rollup that
should run once per week regardless of exactly
when individual records arrived during that
week) rather than reacting to individual file
arrivals
Predictability of run timing matters more than
minimizing latency (a compliance report that
must run at a specific, auditable time)
Event-driven triggers are correct when:
Data arrival timing is variable or unreliable
(the opening scenario's vendor feed)
Each arrival represents a complete, independently
processable unit of work
Minimizing the latency between data arrival and
processing matters for the downstream use case

The decision isn’t “event-driven is always better” — it’s matching the trigger mechanism to the actual relationship between data arrival and when processing should happen, exactly the same reasoning the Databricks series applied to Lakeflow Jobs trigger type selection.


Architecture Flow: The Complete Event-Driven Pipeline

Vendor delivers file(s) to S3
|
v
S3 Event Notification (s3:ObjectCreated:*)
|
v
EventBridge Rule (bucket + prefix filter)
|
v
Lambda — batch debounce check (Blog 10's role:
decide, don'
t do)
|
+-- More files may still be arriving -> wait
|
+-- Quiet period elapsed -> batch complete
|
v
Step Functions Execution Starts (Blog 11)
|
+-- ValidateFileNotEmpty (Lambda)
| |
| +----+----+
| v v
| Valid Empty/Invalid
| | |
| | v
| | AlertEmptyFile (SNS)
| |
| v
| TransformToSilver (Glue,
| Retry: transient failures,
| Catch: validation failures)
| |
| v
| BuildGold (Athena CTAS or
| Glue, per Blog 7's framework)
| |
| v
| NotifySuccess (SNS)
v
Gold Layer, accurately reflecting
exactly the data that arrived

Failure Modes You’ll See in Production

Scheduled trigger running against zero or partial data. The opening scenario. A pipeline scheduled for a time that assumes reliable upstream delivery runs successfully against whatever happens to be present, silently producing stale or incomplete Gold data on the nights delivery timing varies.

Per-file triggering when a debounce pattern was needed. A pipeline triggers on every individual S3 event without a batching check, launching 20 separate Step Functions executions for a 20-file batch delivery — each one processing a fragment of the intended dataset, producing 20 partial transformation runs instead of one complete one.

A fixed delay used instead of a quiet-period check. A team implements “wait 5 minutes after the first file, then trigger” instead of the adaptive quiet-period pattern. On a night the batch takes 8 minutes to fully arrive, the pipeline triggers early and processes an incomplete batch — with no error, because from the pipeline’s perspective it received valid files, just not all of them.

Event-driven trigger without file validation, replacing one silent failure with another. A team migrates from a scheduled trigger to an S3 event trigger, correctly solving the “ran before data arrived” problem, but doesn’t add the empty-file validation Choice state — a genuinely corrupted or truncated vendor file still triggers a “successful” pipeline run that processes zero or garbage rows.

EventBridge rule pattern too broad, triggering on unrelated file arrivals. A rule pattern matches on the bucket alone without a prefix filter, and an unrelated team’s files landing in a different prefix of the same bucket trigger the pipeline unnecessarily — wasting Step Functions executions and Glue job runs on data the pipeline was never meant to process.

Lambda debounce function itself becoming a single point of failure. The batching/debounce Lambda function (tracking arrival timestamps) fails or times out during a batch window, and because no execution was ever triggered, the entire batch silently never gets processed — with no error visible anywhere except the absence of an expected Gold table update, the same class of silent gap the pattern was designed to eliminate, now relocated to a different component.


Trade-offs: What Event-Driven ETL Optimizes For

Event-driven ETL optimizes for:

  • Processing that runs precisely when data is actually ready, eliminating the “ran before data arrived” failure class entirely
  • Minimized latency between data arrival and availability in Gold, compared to worst-case scheduled-trigger latency
  • Natural handling of variable, unpredictable upstream delivery timing

Event-driven ETL doesn’t optimize for:

  • Simplicity — the debounce/batching logic adds real implementation complexity compared to a simple cron schedule
  • Predictable, auditable run timing when that’s actually a requirement (some compliance contexts specifically want “this report always runs at 6 AM,” not “whenever data happens to arrive”)
  • Zero additional failure surface — the trigger chain itself (S3 events, EventBridge rules, debounce Lambda) is now part of what can fail, requiring its own monitoring

The honest trade-off: event-driven triggering trades implementation complexity and an additional failure surface for the elimination of a specific, historically silent failure class. For pipelines where upstream delivery timing is genuinely variable, this trade is clearly worth making. For pipelines with a reliable, guaranteed delivery SLA, a scheduled trigger with appropriate validation may be simpler and equally correct.


Real-World Constraints

EventBridge rule limits per account and region. Large platforms with many event-driven pipelines (connecting to Blog 14’s multi-pipeline scale) need to manage EventBridge rule count within account limits, and rule pattern complexity has its own practical limits worth checking against actual usage before assuming unlimited granularity.

S3 event notification configuration is per-bucket, with limits on notification configurations. A bucket shared across multiple teams and prefixes (Blog 14’s platform-scale scenario) needs careful notification configuration to avoid one team’s event pattern inadvertently interfering with another’s, or hitting per-bucket notification configuration limits as the number of distinct event-driven pipelines grows.

Step Functions execution start rate limits. A very high-frequency file arrival pattern (many small files arriving continuously rather than batched) can approach Step Functions’ execution start rate limits, at which point the debounce/batching pattern from this article isn’t just an architectural nicety — it’s a requirement to stay within service limits.


What This Means for the Rest of the Series

Blog 17 (Lake Formation deep dive): the governance
layer applied to
data landing through
this event-driven
pattern, same as
Blog 13's scheduled
equivalent
Blog 19 (Debugging AWS pipelines): the diagnostic
workflow for tracing
failures specifically
within an event-driven
trigger chain — a
distinct debugging
surface from a simple
scheduled job
Blog 20 (Production checklist): includes an explicit
item for validating that
scheduled triggers are
genuinely appropriate for
each pipeline, versus
defaulting to schedules
out of habit

Summary: The Engineering Lesson

A scheduled trigger encodes an assumption about the world — that data will reliably be ready by a specific time — and that assumption is often wrong in ways that produce no error, just quietly stale output. An event-driven trigger removes the assumption entirely by reacting to the actual signal that matters: data has arrived.

The three silent-stale-data mornings from the opening scenario weren’t caused by a bug in the pipeline’s transformation logic. They were caused by a mismatch between what the trigger assumed (data always ready by 2 AM) and what was actually true (data usually ready by then, but not always) — a gap that no amount of debugging the Glue job’s code would ever have found, because the code was never the problem.

The pattern this article built — S3 events, debounced batching, explicit empty-data validation, Step Functions orchestration — replaces an assumption with a fact. The pipeline runs when data has actually arrived, and it validates that what arrived is real before treating the run as successful. Both pieces are necessary; neither alone is sufficient.


Next in Series

Blog 17 - AWS Lake Formation: Data Governance Without the Complexity

Blog 13 introduced Lake Formation as Unity Catalog’s AWS equivalent. This article goes significantly deeper — column-level security, row-level data filters, and LF-Tags at the implementation depth needed to actually operate Lake Formation as a production governance layer, not just a conceptual mapping.

We’ll go deep on where Lake Formation’s promise of “governance without complexity” holds up and where it doesn’t, with the specific configuration patterns that make the difference.


Comment Below

What’s the most subtle “pipeline ran successfully against the wrong data” failure you’ve caught - or missed?

Was it a scheduled job running before an unreliable vendor’s files arrived, quietly producing stale numbers for days before anyone noticed the pattern? A batch pipeline triggering per-file instead of per-batch, processing fragments instead of complete datasets? A file that arrived on time but was empty or corrupted, triggering a technically successful run over garbage data?

And — what finally exposed the gap between “the pipeline ran” and “the pipeline ran correctly”?


Tags: aws-data-engineering, event-driven-architecture, s3-events, aws-step-functions, aws-glue, eventbridge, etl, dataforge