# Cloud Watch Events abd EventBridge

### **CloudWatch Events**

* A service for monitoring events from AWS services.
* Example: “Every day at 9 AM trigger a Lambda” or “When an EC2 instance state changes, trigger something.”
* Think of it like a basic scheduler + event notifier.

EventBridge (newer, upgraded version)

* EventBridge is basically CloudWatch Events 2.0 (they’re the same service, just evolved).
* It does everything CloudWatch Events does, plus:
  * Accepts events from AWS services, SaaS apps (like Zendesk, Shopify), and custom apps.
  * Has rules to filter, transform, and route events.
  * More powerful integrations (Step Functions, Kinesis, etc.)

**Analogy**

* CloudWatch Events: A school bell — it rings at certain times (schedule) or when something happens (event).
* EventBridge: A full event manager — not only rings the bell but also routes messages between teachers, students, and even parents’ apps with custom rules.

**Flow EventBridge**

1. Event happens → A file is uploaded to S3.
2. Event sent to EventBridge.
3. Rule filters → “Only .jpg files.”
4. Target triggered → Lambda adds a watermark.

### **Event Bus (in EventBridge)**

An event bus is like a channel or pipeline where events are sent and then routed to the right targets.

* Event producers put events on the bus (e.g., S3, EC2, custom apps).
* Rules on the bus decide which events should go where.
* Targets (like Lambda, Step Functions, SNS) receive the event and act on it.

**Types of Event Buses**

1. Default Event Bus
   * Already available in your account.
   * AWS services automatically send their events here (e.g., S3 file upload, EC2 state change).
2. Custom Event Bus
   * You create it for your own apps/events.
   * Example: Your app publishes an event “NewOrderPlaced,” and you route it to a payment Lambda.
3. Partner Event Bus
   * For SaaS apps integrated with AWS (like Zendesk, Shopify, or Datadog).
   * Events from these apps go through this bus.

Analogy

* Think of an event bus like a city bus 🚍:
  * People (events) get on the bus.
  * The bus (event bus) carries them.
  * They get off at the correct stops (targets) based on rules.

<figure><img src="https://1856860631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsNc001Xcz63mWjGXymkd%2Fuploads%2FoZJ3Z1QtCMfhGfi62nnm%2Fimage.png?alt=media&#x26;token=2eb046db-3289-4aa2-9ede-5c4d276f646b" alt=""><figcaption></figcaption></figure>
