Amazon EventBridge is a serverless event bus service that makes it easy to connect your applications with data from a variety of sources. It helps you to build event-driven architectures that are loosely coupled and distributed.
Serverless Event Router – Amazon EventBridge – Amazon Web Services
- EventBridge delivers a stream of real-time data from your applications or AWS services and routes that data to targets such as AWS Lambda using the routing rules.
- EventBridge is the updated version that replaces CloudWatch Events.
Components
Events
- Changes in your resources and sent to EventBridge
- Event Structure
- source
- detail
- detail-type
{
"version": "0",
"id": "ac51d123-45e1-460a-a1fa-e15d188c17e1",
"detail-type": "EC2 Instance State-change Notification",
"source": "aws.ec2",
"account": "123456789101",
"time": "2022-12-25T13:11:28Z",
"region": "us-east-1",
"resources": [
"arn:aws:ec2:us-east-1:123456789101:instance/i-1234567890abcdef0"
],
"detail": {
"instance-id": "i-1234567890abcdef0",
"state": "stopped"
}
}
Destinations
- Targets
- Resources or endpoints that EventBridge sends events to after matching a rule.
- You can configure up to 5 destinations per rule.
Rules
- Rules are the glue in the pipeline.
- A Rule matches an event and sends it to its designated (single or multiple) targets.
- Events can be matched to rules by:
- Rate-based or cron-based schedule
- Event pattern matching
{
"source": ["aws.ec2"],
"detail-type": ["EC2 Instance State-change Notification"],
"detail": {
"state": ["stopping", "stopped"]
}
}
Replay
- Events are saved (archived), and we can replay them later
Event Bus
- “Event Bus” is a serverless pipeline that can deliver events from different sources.
- Every account has a default event bus.
- The default event bus is used for the events from AWS services.
- You can create a custom event bus for custom applications.
- “Rules” are associated with buses and are applied when matching events arrive.
- There is a limit: 300 rules per event bus!
Working with Lambda
- EventBridge can invoke Lambda functions asynchronously.