Amazon EventBridge - Unlocking Event Driven Architecture in AWS [Nov 2020]

dhavaln 78 views 40 slides Sep 04, 2024
Slide 1
Slide 1 of 40
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40

About This Presentation

This presentation highlights key features of Amazon EventBridge and how to build Event-Driven Applications.


Slide Content

Amazon EventBridge
Unlocking Event Driven Architecture in AWS
Dhaval Nagar
12x AWS Certified, AWS Serverless Hero

About me
●12x AWS Certified
●AWS Serverless Hero
●AWS Certification SME
●AWS User Group Leader - Surat
●CEO, AppGambit (AWS Consulting Partner)

Agenda
●Serverless and Events
●What is EventBridge?
●How it works!
●Key Takeaways

Serverless and Events
●Serverless ecosystem is built on top of EVENTS
●Build event driven architectures, which are loosely coupled and distributed
●All the services consume events and react accordingly

Let’s take a simple example system

https://github.com/aws-samples/aws-serverless-ecommerce-platform

Synchronous vs Asynchronous
Service Service
Service
●Multiple APIs, Topics, or Queues
●Manage API Calls with Retries and
Backoffs
●Microservices with strong
dependencies

https://github.com/aws-samples/aws-serverless-ecommerce-platform

Events vs Commands
Order
Service
Events
Something has happened in the
past.
Commands
Something has to happen in the
future.
Payment
Service
Order
placed
Check
payment
Service may fail or not
respond
Warehouse
Service
How to
coordinate ?
Retries and Backoff ?
We need to
add more
features

Queue
Amazon SQS
Pub/Sub
Amazon SNS
Event Bus
Amazon
EventBridge
Integration Options
Stream
Amazon
Kinesis

EventBridge
Serverless Event Bus for your AWS account, your own applications and SaaS providers.

Amazon EventBridge
●EventBridge is built on top of CloudWatch Events
●Uses same API and endpoint and underlying infrastructure
●Consider EventBridge as an extension of CloudWatch Events that allows
external events to be consumed easily
●Existing CloudWatch Events will be available under the EventBridge default
bus
●You can continue using CloudWatch Events as well
●Can create an archive of events to easily replay them at a later time by
starting an event replay

CloudWatch Events
●Existing service under CloudWatch
●Supports scheduled events and AWS service events
●You will see above message when you open CloudWatch Events page
●In EventBridge, you can see all the existing events of CloudWatch under the
default bus

EventBridge Core Components
●Event Bus
●Events
●Rules
●Source and Targets
●Event Schema

How it all looks together

Event Bus
Event buses
●Does routing and filtering of events
●Each account has one default bus
●Create partner event bus to consume partner event data
●Create custom bus for custom application integration
AWS Services SaaS Partners Custom Bus

EventBridge Events
●SaaS Services
●AWS Services
●Custom Events
●Scheduled Events
Events
AWS Events SaaS Events Custom Events
Scheduled
Events

Event Structure
●Envelope structure with high-level
fields and fixed field to pass
payload
●source field contains the AWS
service, partner id or custom URI
scheme like “aws.autoscaling”
●detail-type field contains descriptive
event “EC2 instance created
successfully”
{
"version": "0",
"id": "6a7e8feb-b491-4cf7-a9f1-bf3703467718",
"detail-type": "EC2 Instance State-change
Notification",
"source": "aws.ec2",
"account": "111122223333",
"time": "2017-12-22T18:43:48Z",
"region": "us-west-1",
"resources": [
"arn:aws:ec2:us-west-1:XXX:instance/ i-123..."
],
"detail": {
"instance-id": " i-1234567890a...",
"state": "terminated"
}
}

Rules
●Rule matches incoming events from event bus
●Routes events to targets for process
●Single rule can route to multiple targets
●Rule can customize (transform) an event before sending it to target
●Simplify the processing without a compute layer
●Rules are not processed in any particular order
Event Bus
Event Bus
Event Bus
Rules

Event Patterns
{
"source": [ "aws.ec2" ],
"detail-type": [ "EC2 Instance State-change
Notification" ],
"detail": {
"state": [ "terminated" ]
}
}
Here is the Event and Event Pattern to ACCEPT EC2 Termination Change.
{
"version": "0",
"id": "6a7e8feb-b491-4cf7-a9f1-bf3703467718",
"detail-type": "EC2 Instance State-change
Notification",
"source": "aws.ec2",
"account": "111122223333",
"time": "2017-12-22T18:43:48Z",
"region": "us-west-1",
"resources": [
"arn:aws:ec2:us-west-1:XXX:instance/ i-123..."
],
"detail": {
"instance-id": " i-1234567890abcdef0",
"state": "terminated"
}
}
Event Event Pattern
Note that patterns has ARRAY structure
to accept multiple entries

Complex Event Pattern
{
"time": [ { "prefix": "2017-10-02" } ],
"detail": {
"state": [ { "anything-but": "initializing" } ],
"c-count": [ { "numeric": [ ">", 0, "<=", 5 ] } ],
"d-count": [ { "numeric": [ "<", 10 ] } ],
"x-limit": [ { "anything-but": [ 100, 200, 300 ] } ]
}
}
●Patterns are not restricted to exact match
●There are few custom content filters available to create complex pattern
filtering

Transform Events
●Customize events before it is passed to target
●Define variables to use inside the original event
●Pre-defined variables to use inside transformation

Transform Events
String Template
"instance <instance> is in <state>"

JSON Template
{
"instance" : <instance>,
"state": [ 1, <state>, true ],
"Transformed" : "Yes"
}
Need to provide the input path and template to transform the event before sending
to target.
{
"instance" : "$.detail.instance",
"state" : "$.detail.state"
}
Input Path Input Template
The template could be either a String or
JSON object

EventBridge Source and Target Services
●90 AWS Services as Source
●34 AWS Partners as Source
●17 Target AWS Services
Event Source and Targets
90+ AWS
Services
34 SaaS
Partners
17 Target AWS
Services

Schema and Schema Registry
●Schema is the structure of Event
●Supports OpenAPI 3 and JSONSchema Draft 4
●It shows fields and data types
●It can also include information on patterns
●Schema Registry is kind of documentation of the different events
●Easily identify different events from registry
●Upload schema or auto-detect based on the events passing through
●Auto-generated code bindings based on schema (limited to Java, Python and
TypeScript)

Sample Open API 3 Schema

Receive Events from Other AWS Accounts
●Add the AWS Account ID on your AWS account's default event bus

Send Events to Other AWS Accounts
●Configure a rule that has the default event bus of another AWS account as
the target

Retries and Dead-letter Queues

Vendor Integrations

SaaS Vendors
●As of today there are 34 SaaS partners
●Easy to become EventBridge partner and start publishing events to your
customers
●Salesforce integration is via Amazon AppFlow all others are directly through
EventBridge

Demo

Rate Limits and Billing

EventBridge Pricing
AWS Service events Free
Custom events $1 / million events published
3rd Party events $1 / million events published
Cross-account events $1 / million cross-account events sent
Schema Discovery $0.10 / million events ingested for discovery
Archive Processing $0.12 per GB
Storage / Month $0.0025 per GB
Pay for events published to your event bus, events ingested for Schema
Discovery, and for Event Replay

SNS vs EventBridge
●SNS provides unlimited throughput
●SNS provides latency under 30 msec
●EventBridge has throughput limitations

SQS, SNS, and EventBridge
SQS SNS EventBridge
Messaging 1 to 1 1 to Many 1 to Many
Event Type Single Event Type Single Event Type Multiple Event Types
Route Messages Single Single Multiple Rules
Filter Messages No Only to Message Body Full message
Allows transformation? No No Yes
Cross Account Yes Yes Yes
Message Latency Low Low Moderate
Throughput High High Moderate

New Additions
Archive Events Replay Events

Key takeaways
●Created on top of CloudWatch Events
●Allows to consume events from AWS Services, SaaS Partners, Custom
Applications and Other AWS Accounts
●Events pass-through event buses
●Event bus can have event rules that look for matching event patterns
●Event rules may transform events
●Event rules send the events to Targets like Lambda, EC2 or another AWS
Account
●Easy to consume events from applications like Auth0, New Relic, zendesk,
Datadog, MongoDB Atlas, PagerDuty, etc.

Thank You!
LinkedIn - https://www.linkedin.com/in/dhavaln/