Skip to main content

03. Amazon CloudWatch Events Or Amazon EventBridge

CloudWatch Events evolved into EventBridge — the serverless event bus for AWS, SaaS, and custom applications.

  • Amazon CloudWatch Events was the original AWS service for reacting to AWS system changes and scheduling tasks.
  • Amazon EventBridge is the next-generation version — a serverless event bus that connects AWS services, SaaS applications, and custom apps.
  • Fully backward-compatible: existing CloudWatch Events rules and configurations continue to work in EventBridge.

What is an Event Bus?

An Event Bus is the core component of Amazon EventBridge.
It acts as a central pipeline that receives, filters, and routes events between producers (event sources) and consumers (targets).

🔹 Concept

Think of an Event Bus as a post office for events
AWS services, SaaS apps, or your own applications send events to it,
and EventBridge routes those events to the right targets (e.g., Lambda, SQS, SNS, Step Functions).

🔹 How It Works

Event Source → Event Bus → Rule → Target

StepDescription
Event SourceAWS service, SaaS app, or your custom app emitting events.
Event BusChannel that receives and routes events.
RuleFilters and matches events using patterns.
TargetProcesses matched events (Lambda, SNS, SQS, etc.).

🔹 Types of Event Buses

TypeDescription
Default Event BusAutomatically receives AWS service events (similar to CloudWatch Events).
Partner Event BusReceives events from external SaaS providers (e.g., Zendesk, Datadog, Auth0).
Custom Event BusCreated by you for custom application or microservice events.

🧠 Example

  • Your app emits an OrderPlaced event.
  • The Custom Event Bus receives it.
  • A Rule detects detailType = "OrderPlaced".
  • The Target (Lambda) runs the order fulfillment workflow.

CloudWatch Events

  • Delivers system events about changes in AWS resources.
  • Example: Trigger a Lambda when an EC2 instance changes state.

Key Concepts

  • Schedules (Cron jobs): Create rules that run on a schedule (e.g., hourly Lambda trigger).
  • Event Patterns: React to specific AWS API/service actions (e.g., IAM root sign-in).
  • Targets: Actions to trigger — Lambda, SNS, SQS, Step Functions, etc.

Amazon EventBridge

  • The enhanced version of CloudWatch Events.
  • Supports SaaS, custom application, and advanced event processing.

Key Features

FeatureDescription
Multiple Event BusesDefault, Partner, and Custom buses to organize and route events.
Schema RegistryAuto-discovers and models event structures.
Event ArchiveStores events for compliance or debugging.
Event ReplayReprocesses archived events.
Advanced IntegrationsConnect AWS services and external systems with flexible rules.

Feature Comparison

FeatureCloudWatch EventsEventBridge
OriginOriginal AWS event serviceEnhanced CloudWatch Events
Event SourcesAWS onlyAWS + SaaS + Custom Apps
Event BusSingleMultiple (Default, Partner, Custom)
Schema Registry
Event Archive & Replay
Integration ScopeAWS-onlyAWS + SaaS
Use Case BreadthAWS-centricFull event-driven architecture

Typical Use Cases

Use CaseExample
Serverless SchedulingLambda every hour (cron-style)
Security MonitoringSNS alert on IAM root sign-in
System AutomationTrigger EC2 or ECS tasks
SaaS IntegrationProcess Datadog/Zendesk events
Custom ApplicationsHandle custom business events

Exam Tip

  • CloudWatch Events = old nameEventBridge = upgraded version
  • EventBridge = serverless event bus for AWS, SaaS, and custom events.
  • Key focus areas:
    • Event Buses (Default, Partner, Custom)
    • Rules (Patterns/Schedules)
    • Targets (Lambda, SNS, SQS, Step Functions)
    • Schema Registry, Archive, Replay

✅ All CloudWatch Events features still exist — they’re now part of Amazon EventBridge.


🧩 02. Hands-on: Amazon EventBridge — Rules & Scheduler

Learn how to create scheduled and event-driven rules in Amazon EventBridge
using the AWS Management Console.

In this hands-on, you will:

  1. Create a scheduled rule using EventBridge Scheduler to invoke a Lambda function every hour.
  2. Create event pattern–based rules to:
    • Send SNS notifications when users sign in to AWS Console.
    • Notify when EC2 instances are terminated.

⚙️ Task 1: Create an Hourly Lambda Invocation (EventBridge Scheduler)

1️⃣ Open EventBridge Console

  • Navigate to AWS Console → EventBridge → Create rule.

2️⃣ Create Schedule

SettingValue
Schedule nameInvokeLambdaEveryHour
Schedule typeRecurring schedule
Expression typeRate-based
Rate expressionrate(1 hour)

3️⃣ Configure Target

SettingValue
Target typeAWS Lambda function
Function nameSelect your Lambda (e.g., demoLambda)
  • Leave Flexible time windowOff (executes exactly every hour).
  • Leave retry policy and DLQ as default.

4️⃣ Permissions & Creation

  • AWS creates an IAM role automatically for EventBridge Scheduler.
  • Click Next → Create schedule.

Result:
Your Lambda function is now automatically invoked every hour using the EventBridge Scheduler.

(EventBridge Scheduler is the new recommended way for cron/rate-based tasks.)

IAM Roles Example

⚙️ Task 2: Send Notification on AWS Console Sign-in

1️⃣ Create a Rule

  • EventBridge → Rules → Create rule
  • Rule name: SendNotificationForLogin
  • Event source: AWS events
  • Event pattern type: AWS Console Sign-in events

2️⃣ Define Event Pattern

FieldValue
Service nameAWS Console Sign-in
Event typeSign-in events

3️⃣ Add Target

Target TypeDescription
SNS TopicChoose an existing SNS topic (e.g., demo-ccp-topic).
  • Click Next → Next → Create rule.

Result:
Whenever a user signs into the AWS Console, an SNS notification/email is sent automatically.


⚙️ Task 3: Detect EC2 Termination Events

1️⃣ Create a Rule

  • EventBridge → Rules → Create rule
  • Rule name: EC2InstanceTerminateNotification
  • Event source: AWS events

2️⃣ Define Event Pattern

FieldValue
Service nameEC2
Event typeEC2 Instance State-change Notification
State filter"state": ["terminated"]

3️⃣ Add Target

Target TypeDescription
SNS TopicSend notification to demo-ccp-topic.
  • Click Next → Create rule.

Result:
When any EC2 instance enters the terminated state, an SNS message is triggered.


🧹 Clean Up

To avoid extra cost or unnecessary triggers:

  • Go to EventBridge → Rules → disable or delete the created rules.
  • Or, delete the InvokeLambdaEveryHour schedule.

🧠 Key Learnings

ConceptDescription
EventBridge SchedulerModern replacement for cron/rate rules — ideal for time-based invocations.
Event Pattern RulesReact to real-time AWS events (e.g., login, EC2 state changes).
TargetsLambda, SNS, SQS, Step Functions, etc.
Rules vs SchedulerScheduler = time-based, Rule = event-based.

🧩 Summary

Rule NameTypeTriggerTarget
InvokeLambdaEveryHourScheduleEvery 1 hourLambda function
SendNotificationForLoginEvent patternAWS Console Sign-inSNS Topic
EC2InstanceTerminateNotificationEvent patternEC2 TerminationSNS Topic

📝 Exam Tip

  • EventBridge Scheduler is the new service dedicated for cron/rate expressions.
  • Event Rules handle real-time AWS events.
  • Always remember the flow:
    👉 Event Source → Event Bus → Rule → Target.