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
Synchronous vs Asynchronous
Service Service
Service
●Multiple APIs, Topics, or Queues
●Manage API Calls with Retries and
Backoffs
●Microservices with strong
dependencies
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
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
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.