Amazon EventBridge Overview

Learn how to use Amazon EventBridge to route events for building scalable, event-driven applications.

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.

Press + to interact

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, and time.

  • 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:

Press + to interact
import boto3
events = boto3.client('events')
lambda_arn = "arn:aws:lambda:<Region>:<Account-ID>:function:ProcessOrder"
# Create the rule
events.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 target
events.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:

Press + to interact
EventBridge pipes
EventBridge pipes

These components together enable event producers and consumers to remain loosely coupled, increasing system flexibility and resilience.

How event routing works

When a service ...