Study Guide: Configuring Amazon EventBridge for Pattern-Based Notifications
Configuring EventBridge to send notifications based on a particular event pattern
Study Guide: Configuring Amazon EventBridge for Pattern-Based Notifications
Learning Objectives
By the end of this module, you will be able to:
- Define the core components of Amazon EventBridge, including buses, rules, and targets.
- Construct valid JSON event patterns to filter specific AWS service events.
- Identify appropriate targets (SNS, Lambda, Step Functions) for various notification and remediation use cases.
- Implement event-driven monitoring for critical scenarios such as AWS Health events, S3 object actions, and CodePipeline failures.
Key Terms & Glossary
- Event Bus: A pipeline that receives events. The Default Bus handles events from AWS services, while Custom Buses handle events from your applications.
- Event Pattern: A JSON object used to filter incoming events. If an event matches the pattern, the rule triggers.
- Target: The resource that EventBridge sends an event to when a rule matches (e.g., Amazon SNS topic, AWS Lambda function).
- JSON (JavaScript Object Notation): The data format used for both the event structure and the filtering patterns in EventBridge.
- Asynchronous Design: A pattern where the sender does not wait for the receiver to process the message, facilitating decoupled architectures.
The "Big Idea"
In modern DevOps, polling for status changes (like asking "Is this instance up?" every minute) is inefficient and slow. Amazon EventBridge shifts the paradigm to a reactive, event-driven architecture. By acting as a central "Event Bus," it allows you to listen for specific signals across your entire AWS environment and immediately trigger automated responses, significantly reducing the Mean Time to Detect (MTTD) and Mean Time to React (MTTR).
Formula / Concept Box
Event Pattern Structure
An event pattern must match the structure of the JSON event it is filtering. All fields in the pattern must match the event for the rule to trigger.
| Pattern Key | Description | Example Value |
|---|---|---|
source | The service that sent the event | |
detail-type | The specific type of event | |
detail | A nested object containing specific data | {"state": ["running"]} |
[!TIP] Use the
"detail": {}field to filter on specific attributes like instance IDs, S3 bucket names, or error codes.
Hierarchical Outline
- EventBridge Fundamentals
- Architecture: Sources → Event Bus → Rules → Targets.
- Types of Buses: Default (AWS services), Custom (Apps), and Partner (SaaS).
- Designing Event Patterns
- Matching Logic: Exact matching, prefix matching, and numeric range matching.
- Content Filtering: Using multiple values in an array (OR logic).
- Configuring Targets
- SNS: For human-readable alerts (Email, SMS, Slack via Lambda).
- Lambda: For custom logic and automated remediation.
- Step Functions: For complex, multi-step workflows (e.g., deleting exposed keys).
- Common DevOps Use Cases
- Security: Detecting
AWS_RISK_CREDENTIALS_EXPOSEDvia AWS Health. - Resilience: Monitoring
EC2-initiated maintenanceorRDS Multi-AZ failovers. - CI/CD: Triggering notifications for
CodePipeline Stage Failed.
- Security: Detecting
Visual Anchors
Event Processing Flow
Architectural Diagram: Remediation Workflow
Definition-Example Pairs
- Service: AWS Health
- Definition: A service that provides ongoing visibility into your resource performance and the availability of your AWS services and account.
- Example: An EventBridge rule monitors for an
AWS_EC2_PERSISTENT_INSTANCE_RETIREMENT_SCHEDULEDevent to notify the DevOps team 7 days before an instance is retired.
- Action: Automated Remediation
- Definition: Taking a corrective action automatically in response to an event without human intervention.
- Example: Using a Lambda target to stop an EC2 instance that was launched without the required "Environment" tag.
Worked Examples
Scenario: Notify on CodePipeline Stage Failure
Goal: Send an SNS notification whenever a specific stage in a pipeline fails.
- Step 1: Define the Pattern
Identify the service (
codepipeline) and the state we care about (FAILED).json{ "source": ["aws.codepipeline"], "detail-type": ["CodePipeline Stage Execution State Change"], "detail": { "state": ["FAILED"] } } - Step 2: Create the SNS Topic
Create a topic named
Pipeline-Alertsand subscribe your email address. - Step 3: Create the Rule
- Go to the EventBridge Console.
- Select Create Rule.
- Paste the JSON pattern above.
- Select SNS Topic as the target and choose
Pipeline-Alerts.
- Step 4: Verify Manually fail a stage in your pipeline; check your email for the notification JSON payload.
Checkpoint Questions
- What happens if an event matches multiple EventBridge rules?
- Can EventBridge send the same event to multiple targets simultaneously?
- In an event pattern, does
"source": ["aws.ec2", "aws.s3"]represent an AND or an OR condition? - Which target would you choose to automatically delete an IAM access key found on a public repository?
▶Click to see answers
- The event is processed by all matching rules independently.
- Yes, a single rule can have up to 5 targets.
- OR (It matches if the source is either EC2 or S3).
- AWS Step Functions or AWS Lambda (Step Functions are preferred for multi-step logic).
Muddy Points & Cross-Refs
- EventBridge vs. CloudWatch Events: They are the same underlying service. EventBridge is the evolved version that includes features like Schema Registry and Custom Buses.
- Latency: While EventBridge is fast, it is not strictly "real-time" (typically sub-second). For ultra-low latency requirements, consider direct service integrations if available.
- Input Transformation: If you don't want the full JSON blob sent to your target, use the Input Transformer to extract only specific fields (like
$.detail.instance-id).
Comparison Tables
EventBridge vs. S3 Event Notifications
| Feature | S3 Event Notifications | EventBridge (for S3) |
|---|---|---|
| Setup | Configured on the S3 Bucket | Requires CloudTrail Data Events or S3 EventBridge toggle |
| Targets | SNS, SQS, Lambda | 20+ AWS Services (Step Functions, Batch, etc.) |
| Complexity | Simple, direct | Better for cross-account or multi-service routing |
| Filtering | Basic (Prefix/Suffix) | Advanced JSON patterns |