Lesson 5 of 6 Batch Ingestion and Integration Services

Starting Pipelines on Data Arrival with S3 Events and EventBridge

This lesson explains how event-driven pipelines start processing as soon as data arrives rather than on a fixed schedule, reducing latency and idle compute.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between S3 Event Notifications and EventBridge.
  • Apply common triggering patterns, including batching many small files.
  • Design processing that is safe when events are duplicated or out of order.

S3 notifications vs EventBridge

A pipeline can start as soon as a file lands in S3, and S3 can announce the arrival in two ways. S3 Event Notifications are configured on the bucket and send events directly to a Lambda function, an SQS queue or an SNS topic. They filter only by key prefix and suffix, such as incoming/ and .csv, and are simple to set up.

When EventBridge is enabled on the bucket, every S3 event goes to the default event bus, where rules can filter on any field, such as object size or key patterns, and route the event to many kinds of target, including Step Functions state machines, Glue workflows, ECS tasks, API destinations and other accounts. Events can also be archived and replayed, which helps reprocess files after a failure. The following table summarises the differences.

S3 Event Notifications
TargetsLambda, SQS, SNS only
FilteringPrefix and suffix, e.g. incoming/*.csv
ExtrasSimple
S3 events through EventBridge
TargetsMany: Step Functions, Glue workflows, ECS, API destinations, other accounts
FilteringAdvanced: object size, key patterns, metadata
ExtrasArchive and replay

The following diagram compares the two ways of reacting to a new object.

Two ways for S3 to announce a new object. S3 Event Notifications filter by key prefix and suffix and send to a Lambda function, SQS queue or SNS topic. With EventBridge enabled, events reach the default event bus, where rules filter on any field and route to many targets, and events can be archived and replayed.
Both can be enabled on the same bucket.
Sort into groups

S3 notifications or EventBridge?

Exam skills 1.1.6

Choose how S3 should announce new objects for each requirement.

Log in to try this activity Interactive activities are free with an account.

Common patterns

Ingestion pipelines are usually triggered and coordinated in one of a few ways. When many small files arrive, starting a job for each one is wasteful, so Glue workflows can start from an EventBridge trigger with batching, which waits for a set number of events or a time window, so a job processes a batch of files in one run.

For multi-step pipelines, EventBridge rules start AWS Step Functions state machines, which coordinate the steps with retries and error handling. When processing must be protected from bursts, an Amazon SQS queue between S3 and the processor absorbs them, lets the processor control its concurrency, retries failed messages, and moves repeated failures to a dead-letter queue for investigation.

Match the pairs

Event-driven patterns

Exam skills 1.1.6 · 1.3.1

Match each requirement with the ingestion pattern that fits it.

Log in to try this activity Interactive activities are free with an account.

Designing for duplicates

Events can be delivered more than once and occasionally out of order, so processing must be safe to repeat: use the object key and version as a deduplication key, or write outputs with deterministic names. Avoid recursive loops where a function writes back to the prefix that triggers it.

The following diagram shows a pipeline that processes each partner file exactly once, and where each kind of failure ends up.

Processing each partner file once. An EventBridge rule sends Object Created events to an SQS queue, which feeds a Lambda function with limited concurrency. The function records each object key and ETag with a conditional write, so a duplicate event is skipped while a new version is processed. Bad files go to quarantine, and messages that fail three times go to a dead-letter queue.
The prefix names are illustrative.
Spot the bug

A Lambda that triggers itself

Exam skills 1.1.6 · 1.4.4

Find the lines that cause duplicates and a recursive loop.

Log in to try this activity Interactive activities are free with an account.
Worked example

Processing each file exactly once

Partners drop CSV files into s3://landing/incoming/. Each file must be validated and loaded once, even though S3 events can occasionally be delivered more than once and partners sometimes re-upload the same file.

ConcernDesign
TriggerEventBridge rule on Object Created for the prefix, targeting an SQS queue
Absorb burstsThe queue feeds a Lambda function with limited concurrency
Duplicate eventsRecord each object key and ETag in DynamoDB with a conditional write; skip if already present
Bad filesMove to a quarantine/ prefix and notify the partner
Failed processingDead-letter queue after three attempts

The idempotency record makes duplicates harmless: a second event for the same object and ETag is ignored, while a genuinely new version of the file (a new ETag) is processed.

Check yourself

How can a Glue workflow start only after 100 new files have arrived?

Show answer

With an EventBridge trigger configured with a batch size of 100.

Exam Tips

Remember for the exam

  • To start a Step Functions pipeline when a file lands, route S3 events through EventBridge to Step Functions.
  • To start a Glue workflow after 100 files arrive, use an EventBridge trigger with a batch size.
  • To buffer bursts of S3 events and retry them, use SQS with a dead-letter queue.
  • To filter on object size or reach many kinds of target, use EventBridge rather than plain S3 notifications.
  • Because events may be repeated, make processing idempotent.