Lesson 4 of 5 Data Pipeline Orchestration

Scheduling and Triggering Pipelines with Amazon EventBridge

This lesson explains how Amazon EventBridge starts pipelines at a set time with EventBridge Scheduler or when something happens with event rules that react to changes in AWS services and applications.

Learning outcomes

After completing this lesson, you will be able to:

  • Create schedules with EventBridge Scheduler.
  • Write event rules that react to service events.
  • Choose between scheduled and event-driven starts.

EventBridge Scheduler

Amazon EventBridge Scheduler starts targets at defined times. Schedules can run once or recur, defined with cron expressions, such as 02:00 every weekday, or rate expressions, such as every 15 minutes. Each schedule has a time zone, and daylight saving time is handled automatically, so a pipeline scheduled for 06:00 local time runs at 06:00 all year. Flexible time windows spread invocations over a period when exact timing does not matter.

Failed invocations are retried according to a retry policy and can be sent to a dead-letter queue. Universal targets let a schedule call hundreds of AWS API actions directly, such as starting a Glue job or a Step Functions execution, so no Lambda function is needed just to start a pipeline.

True or false

EventBridge Scheduler

Exam skills 1.1.5 · 3.1.9

Decide whether each statement about EventBridge Scheduler is true.

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

Event rules

Many AWS services report what happens to them as events, and EventBridge rules turn those events into pipeline actions. Amazon S3 reports objects created in a landing prefix, which can start ingestion as soon as a file arrives. AWS Glue reports job state changes, crawler completion and Data Quality results, which can start the next step or raise an alert when a job fails. Amazon EMR and Step Functions report step and execution status, and the Redshift Data API reports when a statement finishes. Applications can also put their own events on a custom event bus. The following table summarises the common sources.

Event sourceExample events
Amazon S3Object created in a landing prefix
AWS GlueJob state change, crawler completion, Data Quality results
Amazon EMR, Step FunctionsStep or execution status changes
Amazon RedshiftData API statement completion
Custom applicationsEvents put on a custom event bus

The following diagram shows the event pattern and alert path that report failed production Glue jobs without changing them.

Alerting on failed production Glue jobs without changing them. Glue publishes job state change events, an EventBridge rule matches FAILED and TIMEOUT for jobs named prod-, and its SNS target notifies the team's chat channel. An EventBridge Scheduler schedule with a time zone starts the jobs at 02:00 London time.
The scenario is illustrative.
Match the pairs

Event sources

Exam skills 1.1.6 · 3.1.9

Match each pipeline action with the event that should start it.

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

Scheduled or event-driven?

Whether a pipeline should run on a schedule or on events depends on how data arrives and when results are needed. When processing must happen at a fixed business time, such as 02:00 local time, EventBridge Scheduler runs it, with time zone support. When files arrive irregularly and should be processed promptly, an event rule on S3 object creation starts the pipeline for each file. When many small files arrive, processing each one separately is wasteful, so Glue workflow event batching or a schedule groups them into one run. The following table summarises the choice.

SituationTrigger
Data must be processed at a fixed business time, such as 02:00 local timeEventBridge Scheduler
Files arrive irregularly and should be processed promptlyEvent rule on S3 object creation
Many small files arrive and should be processed togetherEvent rule with Glue workflow batching, or a schedule
Sort into groups

Schedule or event?

Exam skills 1.1.5 · 1.1.6

Choose how each pipeline should be triggered.

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

Alerting on a failed Glue job

The data team wants a message whenever any production Glue job fails, without changing the jobs. An EventBridge rule with the following event pattern matches the failures.

{
  "source": ["aws.glue"],
  "detail-type": ["Glue Job State Change"],
  "detail": { "state": ["FAILED", "TIMEOUT"], "jobName": [{ "prefix": "prod-" }] }
}

The rule targets an SNS topic connected to chat through Amazon Q Developer in chat applications. Because Glue publishes these events itself, no job code changes, and every new job named prod-... is covered automatically. The jobs themselves are started at 02:00 London time by an EventBridge Scheduler schedule with a time zone, so daylight saving time is handled.

Check yourself

Which service runs a pipeline every night at a set time in a particular time zone?

Show answer

EventBridge Scheduler, which supports time zones and can start a Glue job directly through a universal target.

Exam Tips

Remember for the exam

  • For a nightly schedule in a particular time zone, use EventBridge Scheduler.
  • To start a pipeline when a file lands, use an EventBridge rule on S3 events.
  • EventBridge Scheduler can start a Glue job directly through a universal target.
  • To react to Glue job failures, use an EventBridge rule on Glue job state changes.
  • Scheduler retries failed invocations and can send them to a dead-letter queue.