AWS — Amazon EventBridge — Event Bus Explained

Explore Amazon EventBridge in this comprehensive guide, covering its core components, features, benefits, and use cases, and learn how it revolutionizes real-time data processing, application integration, and workflow automation.

Ciaran O'Keeffe
Dev Axe
7 min readAug 29, 2023

--

Introduction

Amazon EventBridge is a serverless managed service that enables you to build event driven applications and services, via 3 different feature sets:

  • EventBridge Event Bus
  • EventBridge Pipes (part 2 of series)
  • EventBridge Scheduler (part 3 of series)

Amazon EventBridge was launched at AWS re:Invent 2019 and is an evolution of a service called Amazon CloudWatch Events, which was launched in 2016. EventBridge Pipes and EventBridge Scheduler are new features that were added in late 2022 extending the use cases and functionality of the EventBridge service. EventBridge still uses the CloudWatch Events API under the hood.

EventBridge Event Bus - Core Components

Amazon EventBridge is a serverless event bus that allows you to receive events from a source, filter and transform the event using rules and finally route/deliver those events to targets. Here, I have mentioned some of the core components of EventBridge Event Bus, but lets explore each of the moving parts in a little more detail.

Sources

Sources are the origins of events. They can be existing AWS services (e.g. Amazon S3, CloudTrail, etc), SaaS partner applications, other accounts or your own applications. EventBridge has a large number of SaaS partner integrations as event sources, including but not limited to Datadog, Auth0, MongoDB, PagerDuty and Segment. A full list of supported partners is available here.

Events

Events are data payloads that describe a change in an environment or some other event source. An event is represented as a JSON object. EventBridge allows users to define custom event schemas or use pre-built schemas based on AWS services or event sources of SaaS partner applications. Events can have similar structure but all must have the same top-level fields of detail, source and detail-type fields. Custom events need to have these fields at a minimum. These will be discussed more in the “Rules” section below.

Bus

Event buses are the routing layer that connect sources to targets. EventBridge offers two types of event buses; a default event bus per region and the ability to create custom event buses. The default bus is a shared bus that can receive events from all sources and can be used to route events to any existing AWS service, SaaS application, or custom application. A custom event bus is a dedicated bus that can be used to isolate events from specific sources and send data or deliver events to specific targets.

Rules

Rules define how events are matched and how to route/deliver events to targets, allowing you to filter your events based on your specific needs. EventBridge allows users to create rules based on specific event patterns, custom patterns, or pre-built patterns based on AWS services or SaaS applications. You can also schedule rules based on a cron schedule or one off schedule. See “Schedule” for further details.

Amazon S3 "Object Created" Event

{
"source": ["aws.s3"],
"detail-type": ["Object Created"],
"detail": {
"bucket": {
"name": ["myeventsourcebucket"]
}
}
}

Custom Event

{
"source": ["mycustomapp"],
"detail-type": ["NewUserCreated"],
"detail": {
"user": {
"email": ["newuser@tesing.com"],
"name": ["Joe Bloggs"],
"time": ["2021-11-12T00:00:00Z"]
}
}
}

You can extend how rules are processed using content-based event filtering, causing the rule to execute only when certain filtering conditions are met in the event data and the event matches the pattern selected.

It supports the following types of pattern matching:

Prefix Matching Rule

{
"time": [ { "prefix": "2017-10-02" } ]
}

Suffix Matching Rule

{
"FileName": [ { "suffix": ".png" } ]
}

Anything-but Matching Rule

"detail": {
"state": [ { "anything-but": [ "stopped", "overloaded" ] } ]
}

Numeric Matching Rule

"detail": {
"c-count": [ { "numeric": [ ">", 0, "<=", 5 ] } ],
"d-count": [ { "numeric": [ "<", 10 ] } ],
"x-limit": [ { "numeric": [ "=", 3.018e2 ] } ]
}

IP Address Matching Rule

"detail": {
"sourceIPAddress": [ { "cidr": "10.0.0.0/24" } ]
}

Exists Matching Rule

"detail": {
"c-count": [ { "exists": false } ]
}

Equals-ignore-case matching Rule

"detail-type": [ { "equals-ignore-case": "ec2 instance state-change notification" } ]

Multiple Matching Rule

"time": [ { "prefix": "2017-10-02" } ],
"detail": {
"c-count": [ { "numeric": [ ">", 0, "<=", 5 ] } ],
"d-count": [ { "numeric": [ "<", 10 ] } ],
"x-limit": [ { "anything-but": [ 100, 200, 300 ] } ]
}

Or Matching Rule

"detail": {
"$or": [
{ "c-count": [ { "numeric": [ ">", 0, "<=", 5 ] } ] },
{ "d-count": [ { "numeric": [ "<", 10 ] } ] },
{ "x-limit": [ { "numeric": [ "=", 3.018e2 ] } ] }
]
}

For example, in the custom event pattern above you might want to pass the event only if it occurred on a certain date. To do this you could use prefix matching as follows;

"time": [ { "prefix": "2021-11-12" } ]

This would match all events created on that date, regardless of the time.

Targets

Targets are the endpoints that receive events. Like sources, they can be existing AWS services, SaaS applications, or custom applications. EventBridge offers a wide range of targets, including Amazon Kinesis, Amazon SNS, AWS Lambda functions, and even custom targets, including API Destinations. API Destinations enables you to use Amazon EventBridge to send events to HTTP endpoints or Lambda functions. API Destinations are useful when you need to integrate with a custom application that is not available as a pre-built target, making the use of EventBridge extremely extensible for even the most complex use cases.

Schedule

Schedule enables you to create events on a schedule. EventBridge allows users to create rules that trigger events at specific times (cron) or intervals (rate). This service is being superseded by AWS EventBridge Scheduler. I will be creating an additional blog post on this feature set.

Archives & Replays

Archives provides a permanent, immutable and queryable record of events. When you create an archive in EventBridge, you can determine which events are sent to the archive by specifying an event pattern. EventBridge sends events that match the pattern to the archive. You also set the retention period to store events in the archive before they are discarded.

Replays enables you to replay events from your archive in order to reprocess them at a later time. For example, you might want to replay events to recover from errors or to test new functionality in your custom application.

Schema Registry

Schema Registry is a feature that enables you to manage schemas for events. This enables developers to write, store and centrally manage downloadable code schemas for any given target/multiple targets that will process their events from EventBridge. Developers can easily create code bindings or generate events.

Global Endpoints

Global Endpoints offer a simple method for improving the availability and dependability of your event-driven applications. Using replication rules, it enables automatic redirection of event ingestion to a backup Region in the event of a service disruption. Global Endpoints offer the choice of managed event replication, streamlining setup and reducing the potential for event loss during regional service outages.

Benefits of EventBridge

Some benefits of Amazon EventBridge Event Bus are:

  • Serverless Service: EventBridge is a fully managed service that eliminates the need for users to manage infrastructure or servers.
  • Cost effective: EventBridge is a pay as you go service, you only pay for what you use. See “Pricing” below for further details.
  • Easy to use: EventBridge offers the intuitive EventBridge console and API that makes it easy for users to create and manage event-driven architectures. It is also supported by most Infrastructure as Code platforms including AWS Cloudformation and AWS CDK.
  • Easy to monitor: EventBridge has integration with Amazon CloudWatch and AWS X-Ray making monitoring and debugging your application or service relatively straightforward.
  • Easy to integrate: EventBridge offers pre-built integrations with many popular AWS services and SaaS partners, making it easy to connect applications together. Using API Destinations makes it easy to integrate your events with any HTTP endpoint also.

When to Use EventBridge Event Bus

Amazon EventBridge is a versatile service that can be used in a variety of use cases. Some examples of when to use Amazon EventBridge are:

  • Event-driven architecture: EventBridge allows users to create event-driven architectures (EDAs) easily, enabling them to build highly scalable and decoupled/loosely coupled applications.
  • Real-time data processing: EventBridge can be used to process events in real-time, enabling users to build real-time applications and services.
  • Integrating applications: EventBridge can be used to integrate applications together, again enabling users to build highly scalable and decoupled/loosely coupled architectures and serverless applications.
  • Automating workflows: EventBridge can be used to automate workflows and trigger actions based on specific events.

EventBridge Event Bus Pricing

Pricing will vary based on how you use the service, but below is an indicator of the prices charged. You are not charged for rules or event buses.

  • AWS default service events - Free
  • Custom events - $1.00/million events published
  • Third-party software as a service (SaaS) events - $1.00/million events published
  • Cross-account events - $1.00/million events sent

This post originally appeared at https://www.akeero.com/post/aws-amazon-eventbridge-event-bus-explained

--

--

Ciaran O'Keeffe
Dev Axe
Editor for

Security enthusiast and co-founder/CEO of Akeero