AWS EventBridge

Learn via video courses
Topics Covered

Overview

AWS EventBridge is a fully managed service that takes care of event ingestion and delivery. It also takes care of security, authorization, and error handling. It delivers a real-time data stream from applications to targets (usually AWS Lambda functions and HTTP endpoints ). It runs a highly scalable serverless event bus. AWS EventBridge is used with minimum to no coding involved. Formerly known as AWS Cloudwatch Events, Amazon EventBridge uses the same Cloudwatch Events API.

What is AWS EventBridge?

AWS EventBridge is a serverless event bus. It connects application data from our apps, SaaS, or AWS services to targets such as Amazon SNS or AWS Lambda.

What is AWS EventBridge

Let's try to understand it from the basics.

Serverless applications communicate using Events. The entire infrastructure is divided into sources and targets. The source includes API Gateway, databases, etc., which emits the stream of data events. The target components, such as Lambda functions, react to these events to complete the task.

Now we know the importance of events in a serverless architecture. Using AWS EventBridge, we can easily create, inject and react to events. It is a serverless service that makes it easy to work with events. It allows us to set up routing rules to determine where the data needs to be sent.

How Does AWS EventBridge Work?

Let's talk about how Amazon EventBridge works. It is a serverless event bus that supports the publish/subscribe model that fans out the events to one or multiple AWS target services.

The first step is to create a rule in the same region where the target is present. Next, a rule needs an event pattern to match the incoming events. Here is an example to understand the event template. Given below is an event template for the EC2 termination event.

Finally, each rule has to be associated with an event bus. We have to select one of the event buses based on our requirements. Then, match with the event pattern by the rule; after that, we choose the target to which the events will be routed.

The next step is to create an event bus. We have a default event bus, which accepts events from AWS services. We can also configure our custom applications to send events to the default event bus. A partner event bus is also created to integrate with a SaaS partner application.

AWS EventBridge Work

We will try to understand the working of AWS Eventbridge with reference to the above diagram.

  • Here on the left side, we can see a bunch of sources.
  • The Event source can be any AWS service, custom applications, etc.
  • When an event occurs, let’s say an EC2 instance was stooped, you received an order in a custom app, or maybe a new ticket was created in a SaaS application. These are all events occurring in the source system.
  • When any such event occurs, the event is sent to Amazon EventBridge.
  • In the Amazon EventBridge, we have a default event bus.
  • This default event bus is wired to almost all AWS services. For our custom applications, we can create a custom event bus. Even for our SaaS applications, we can create a partner event bus.
  • The event is taken to Schema Registry. Schema Registry confirms if this is an expected event.
  • AWS Eventbridge checks for the rule that matches this event if the event is expected. This rule contains the target information. It tells where the event needs to be directed.
  • Then the event is redirected to the specified target.

Additionally, we can add some features, such as content-based event filtering, schema registry, transforming target inputs, etc.

Content-Based Event Filtering

This feature allows events to be processed based on some filtering condition. For example, you might want an event from a particular IP executed.

Content-based event filtering includes the following pattern matching:

  • Prefix
  • Anything-but
  • Numeric
  • IP Address
  • Exists
  • Complex Example with Multiple Matching

Transforming Target Inputs

Sometimes, you might want to customize the event fields before sending them to the targets.

Take, for example, the event below that is being processed.

While creating the rule, you can select the Input Transformer option present under configure input. You are provided with two options Input path or Input template.

The variable instance and state can be used to define the Input path.

The input template is used to alter the information passed to the target. It is also created to pass string or JSON to the target. For example: Template

Output

AWS Eventbridge Schema Registry

The developer needs to write a script matching the event received. If this is done manually, it can be cumbersome.

To solve this, AWS used Schema Registry. It is used to centralize and share the event structure. This event structure can be downloaded as objects using Java, Python, etc.

Components of AWS Eventbridge

There are various components involved in the entire process of AWS Eventbridge usage:

Components of AWS Eventbridge

Event

An event can be a real-time change in environment, some actions being taken, or the occurrence of some scheduled action. They are represented in JSON messages, which follow some standard templates.

Event Sources

Sources are any service that sends events to the bus so they can be forwarded to the target and trigger some task.

Let’s consider an example of a customer subscribing to an online service. Here the subscription component is the source that needs to inform the other services known as targets to trigger a task, say send a confirmation mail.

Event Buses

The Event bus is the leading service component. It receives the event and routes the events to a specified target. The event bus needs to be configured in AWS to facilitate event listening by sources.

There are three types of buses:

  1. Default event bus: This is created by default. It is capable of receiving events from any AWS service.
  2. Custom event bus: This needs to be created. It is capable of receiving events from custom applications.
  3. Partner event bus: This also needs to be created manually. It is capable of receiving events from SaaS partner applications.

Targets

Targets receive the event from the event bus in JSON format. It can be any AWS service like AWS Lambda, SNS, EC2 instances, Step functions, etc.

Rules

These are a set of instructions for the Event bus. Using this rule event bus scans the event to be matched. It contains information like where the event-related data needs to be sent, i.e., the target.

Each rule can route an event to one or multiple targets. We need to enable parallel processing to route an event to various targets.

Schema Registry

Schema is nothing but a template that contains the structure expected from an event message. All the AWS services schemas are registered in the Schema Registry by default. For the custom apps, the schema needs to be created and uploaded to the schema registry.

AWS Eventbridge Features

Let’s explore some features of AWS Eventbridge:

API Destinations

  • API destinations helps developers send events back to Software as a Service (SaaS) Applications while controlling the throughput and authentication.
  • The events can be sent to any web application which has an address.
  • We can implement API destinations with integration.

SaaS Integration

  • AWS Eventbridge is preconfigured with many SaaS applications, including Datadog, OneLogin, Symantec, Whispir, and Zendesk.
  • AWS manages the integration configuration, such as authentication events from the SaaS provider.

Monitoring and Auditing

  • To analyze and monitor the number of times an event matches a rule or how many times a target is invoked, we can use AWS CloudWatch for this.
  • We can also track calls to the Amazon EventBridge API using AWS CloudTrail.

Security

  • AWS Eventbridge can be integrated with other AWS services like AWS IAM (Identity Access Management) to increase security.
  • This integration can manage access controls and permissions to resources and data.

Scheduled Events

  • Unix cron can be used to schedule events in Amazon Eventbridge.
  • These scheduled events are generated periodically.
  • They are capable of invoking any AWS services.

Event Filtering

  • Rules can be added to filter events. Usually, the workflow goes like this; the incoming events are matched to the given constraints, which are then routed to the target for processing.
  • This rule adds to the flexibility of filtering events based on interest.
  • You can have multiple regulations which match a given event or various events matching a given rule.

Reliability

  • Events are stored across multiple availability zones to enhance durability.
  • Storing the event in multiple places guarantees the delivery of the event to the target destination.
  • Amazon Eventbridge provides a 99.99% availability service level agreement (SLA).

Use Cases of AWS EventBridge

Let’s take some use cases of AWS EventBridge.

Customize SaaS with AI/ML

AWS Event Bridge customizes SaaS with AI/ML. We can quickly load the data from a SaaS application to AWS EventBridge and use artificial intelligence and machine learning (AI/ML) to tag images of new retail products.

Extented Functionality with SaaS Integration

AWS EventBridge extends its functionality with SaaS integrations. It effortlessly connects the applications with the other SaaS application. We can send a custom event to AWS EventBridge, and then send it through API Destinations to Zendesk CRM.

Monitor and Audit Applications

AWS EventBridge helps to monitor and audit our AWS environment and respond to operational changes in the applications. These changes are done in real time, which also prevents infrastructure vulnerabilities.

Decoupling Microservices

Amazon Eventbridge is comparatively a great service for implementing asynchronous messaging service for microservcies.This involves asynchronous messaging in order to decouple independent services.

Workflow automation

Amazon Eventbridge easily connects to third party services such as SugarCRM. SugarCRM is an open source tool which is cloud based cutomer relationship manager.Using SugarCRM integration the workflow of customer services and sales activities can be easily automated.For example, if an event occurs where we have a sale, the invoice can be automatically genrated.

Flexibility

Amazon Eventbridge is quite flexible in nature. It can be integrated with numerous AWS services and also third party apps. This integration with other tools increases functional use at both ends and is capable of providing better results.

AWS EventBridge Comparison with other AWS Services

Let's try to understand how AWS Eventbridge is different from other AWS services.

CloudWatch Events vs AWS EventBridge

To understand the comparison between CloudWatch Events and AWS EventBridge, let us assume that an employee resigns from an organization and his record is updated in the CRM tool. As part of an exit checklist, we have to trigger different workflows for all approvals.

If we solve this situation using CloudWatch Scheduler, it uses the SNS and lambda functions, but we can do all this by using AWS EventBridge. The below figure shows how the design looks in the AWS EventBridge case than in CloudWatch Event services.

CloudWatch Events vs AWS EventBridge

SNS vs AWS EventBridge

To understand the comparison between SNS and AWS EventBridge, let us suppose we have to build a system in which, if an ec2 instance is down, reboot it and trigger a Lamda function to store the incident of the DynamoDB table.

We can solve this situation using AWS SNS as an event routing service and SQS. Still, if we implement the AWS EventBridge to solve this situation, we can easily do that. The figure below shows the design in the AWS EventBridge case rather than in services using SNS and SQS.

SNS vs AWS EventBridge

Kinesis vs AWS EventBridge

Kinesis is used in event routing and storing, an ideal solution for processing large-scale real-time data. It provides ordering guarantees. However, like AWS EventBridge, it doesn’t have an entirely usage-based pricing model and does not automatically scale to demand.

AWS EventBridge Pricing

Event Buses

By default, the events published by AWS services are free. The pricing varies from region to region for other events like custom events, SaaS events, etc.

In the image given below, we can see the standard pricing for the US East region.

Event Buses

API Destinations

API destinations send events from the source to AWS EventBridge, then to some web-based applications as a target. The standard pricing varies region-wise. For each 64kb of payload, one event is counted. The below table contains pricing for the US East region.

API Destinations

Event Replay

Event replay follows the exact pricing as the custom events. The standard pricing varies depending on the region. For the US East region, the pricing follows the structure shown in the table below:

Event Replay

Schema Registry

Schema registry can be used for free in the case of AWS and custom events. It includes a free tier under which 5 million ingested events can be made per month. A charge for events outside the free tier is made for each 8kb(taken as one event). The standard pricing for the US East region is shown in the table below.

Schema Registry

Benefits of AWS EventBridge

Listed below are the benefits of using Amazon Eventbridge:

Easy to Scale and Manage

  • AWS Eventbridge includes components like Event schemas and Schema registry.
  • These components make the management of large-scale applications easier.
  • The schemas make the events easily discoverable or trackable by developers.
  • Schema Registry provides a centralized communication channel for the team of developers working with the events.
  • The increase or decrease in events can be easily taken care of using the schemas.

Asynchronous Pattern of Messaging

  • AWS Eventbridge is the best tool to implement asynchronous messaging patterns on the cloud.
  • AWS Eventbridge provides a loosely coupled architecture.
  • The components involved are isolated.
  • It provides the facility to extend or replace services easily.

Single-bus Architecture

  • AWS Eventbridge maintains a single bus for all related or unrelated events.
  • It provides us with the option to create multiple buses if needed.
  • Sometimes it becomes cumbersome to manage huge amounts of unrelated events; in those cases, one can opt for multiple buses.

Write Less Custom Code

  • To use AWS Eventbridge, minimal coding is required.
  • Schema registry contains inbuilt templates of some common events.
  • The code bindings for these predefined schemas can be easily downloaded.

Reduce Operational Overhead

  • It prevents us from the hassle of installing and maintaining a server.
  • In order to use AWS Eventbridge, no external software is needed.
  • Developers can focus on functionality rather than infrastructural performance.

Conclusion

Within this article, we learned the following:

  • AWS EventBridge is a fully managed AWS service that takes care of ingestion and delivery.
  • Amazon Eventbridge supports serverless architecture.
  • It comprises components that include source, events, event bus, schema registry, and targets.
  • Events correspond to some change in the state of the working environment. This change is experienced in some sources like an AWS service, a custom app, a SaaS app, etc.
  • The event is routed to the target with the help of an event bus which stores the event to deliver them to the right target destination.
  • The schema registry contains rules that map an event to a given target.
  • Differences between AWS Eventbridge and other AWS services like Cloudwatch etc.
  • The pricing of AWS Eventbridge varies from region to region. The custom events and AWS events come under the free tier.