Amazon EventBridge Overview
Learn how to use Amazon EventBridge to route events for building scalable, event-driven applications.
We'll cover the following...
- Introduction to Amazon EventBridge
- Core concepts and components
- How event routing works
- Emitting custom events
- EventBridge Schema Registry
- Fanout pattern and choreography
- Asynchronous and stateless integration
- Delivery guarantees and latency considerations
- Idempotency in event processing
- IAM permissions and cross-account event delivery
- Monitoring and error handling
- Conclusion
In this lesson, we explore Amazon EventBridge as a foundational service for building event-driven applications on AWS. EventBridge enables developers to create scalable, loosely coupled systems by routing events from AWS services, SaaS applications, and custom sources. We focus on its architecture, event routing logic, developer integrations, security best practices, and monitoring capabilities.
Introduction to Amazon EventBridge
Amazon EventBridge is a serverless event bus service designed to simplify communication between application components using events. It ingests events from AWS services, custom applications, and integrated SaaS partners, and routes them to targets like AWS Lambda, Step Functions, and SNS.
Some documentation or exam questions may refer to "Amazon CloudWatch Events". This is simply the earlier name for what is now known as EventBridge. The service has since evolved with added capabilities like schema discovery, partner event sources, and advanced filtering.
Core concepts and components
An EventBridge architecture consists of several key elements:
Event buses: Channels for routing events. There are three types: the default event bus, custom event buses, and partner event buses.
Source: The origin of the event, such as a custom application, an integrated SaaS platform, or an AWS service that emits events.
Targets: AWS services that respond to events, such as Lambda functions, Step Functions, SQS queues, or SNS topics.
Events: JSON-formatted messages describing a state change or action. Events typically include a
source
,detail-type
,detail
, andtime
.Rules: Define matching patterns and specify one or more targets to route matching events to. To programmatically configure routing, we can define a rule and specify one or more targets. For example, here’s how we can create a rule that listens for high-value orders and routes them to a Lambda function:
import boto3events = boto3.client('events')lambda_arn = "arn:aws:lambda:<Region>:<Account-ID>:function:ProcessOrder"# Create the ruleevents.put_rule(Name="HighValueOrderRule",EventPattern='''{"detail-type": ["order_placed"],"detail": {"amount": [{"numeric": [">=", 100]}]}}''',State="ENABLED",Description="Trigger Lambda for high-value orders",EventBusName="default")# Attach the Lambda function as a targetevents.put_targets(Rule="HighValueOrderRule",Targets=[{"Id": "TargetFunction","Arn": lambda_arn}])
EventBridge pipes: EventBridge pipes connect a source and a target and support point-to-point integration. They allow us to filter and enrich the events sent to a destination. The following illustration gives an overview of how a working EventBridge pipe looks:
These components together enable event producers and consumers to remain loosely coupled, increasing system flexibility and resilience.
How event routing works
When a service ...