- Hi, my name is Talia Nassi,
and I'm a senior developer advocate here at AWS Serverless.
In this video, you learn how to perform
an event discovery exercise with your team.
It shows how to create a schema registry
with Amazon EventBridge and how to represent the event
as an object in your code to use in your application.
Event-driven architecture at its core is driven by producers
creating events and subscribers being made aware
of those events and acting upon them.
An event is a data representation
of something that happened elsewhere in the application
or from an outside producer.
When building event-driven applications,
it is critical to determine what events exist
in the application, who produces them
and who subscribes and reacts to them.
The first step in identifying these events
is to work through the process of event discovery.
In this process, you decide the events
that the event source produces
and what parts of the application must know
about those events.
Event schemas describe the structure of an event
and fields included in the event.
If the event's contents match
the event target's requirements,
the service sends the event to the target.
If you have an existing application
that you want to discover event schemas
automatically for you,
you can enable the Amazon EventBridge schema discovery.
If you're building a new application,
you can conduct an event discovery exercise.
An event bus connects the event to the subscriber.
The event bus at AWS is Amazon EventBridge.
Use EventBridge to choreograph interactions
between event sources and event targets.
Notice that events are not technical
or focused on implementation.
Rather, they are real world things
that happened in your system.
This is because everyone from developers to product donors
must understand them.
In the event discovery phase,
events act as your business requirements.
Later, developers then translate
those requirements into code.
Once you have the events laid out,
you decide who's interested in each event.
For example, consider the events listed
for an example e-commerce application:
account created, item added to cart and order placed.
Whenever a user creates an account,
the marketing team subscribes to that event
to send the account holder promotions.
The security team encrypts the account holder's
username and password into a database
to save the account credentials.
Whenever a user places an order, the system sends a message
to the fulfillment team to start packing
and shipping the order.
This approach decouples the interactions
between all of these services.
This decoupling is beneficial
because it increases developer independence
by reducing the dependencies
on other teams to write integrations.
Once the initial event schema planning is complete,
you wanna ensure that developers
can continue to build new features
without needing to coordinate with other teams closely
on event schemas.
For this reason, EventBridge's schema registry
and automated schema discovery can help developers
quickly build new features
based on their application's events.
You use EventBridge schema registries
to search for, find and track different schemas
generated by your application.
You also can automatically find schemas
with the automated schema registry.
Applications can have many different types of events.
Events generated from AWS Services,
third-party SaaS applications
and your custom applications.
With so many event sources, it can be challenging
to know what to expect when consuming events.
A schema represents the structure of an event.
It describes what happened at the event,
where the event came from and the timestamp.
The event schema is important for developers
as it shows what data contained in the event
and allows them to write code based on that data.
For example an order placed event might always contain
a list of items in the order as an array
and a user ID as an integer.
EventBridge helps automate the manual process
of finding and documenting schemas.
There are two capabilities to highlight:
the schema registry and schema discovery.
A schema registry is a repository
that stores a collection of schemas.
You can use a schema registry to search for,
find and track different schemas
used and generated by your application.
AWS automatically stores schemas for all AWS sources
for EventBridge in your schema registry.
SaaS and custom schemas can be generated and added
to the registry using the schema discovery feature.
A schema registry enables you to use events
as objects in your code more easily.
In this tutorial, you add an event
to the Amazon EventBridge schema registry.
You create an account, create an event,
which includes a user's name and email address.
Navigate to the Amazon EventBridge console
and choose Schemas from the left panel.
There are three types of schemas represented in the tabs:
AWS event schema registry, Discovered schema registry
and Custom schema registry.
When you choose AWS event schema registry,
you can search for any AWS service or event
that is supported by EventBridge.
There you can view the schema for that event.
To create a custom schema registry for your application,
navigate to the Custom schema registry tab
and choose create registry.
Enter a name for the registry and then choose Create.
There are currently no schemas in the registry
so choose create custom schema to create one.
Choose your registry as the destination
and call the schema user.
You can choose to load the schema template
using an open API format from the load template option.
You can then manually enter data for each of the fields.
Alternatively, you can have the service
discover the schema from JSON.
Remember that events are written in JSON.
Choose the discover from JSON tab
and enter the following code:
ID 1, name Talia Nassi,
email address talia@thisismyemail.com.
Then choose discover schema.
EventBridge extrapolates the schema from this information.
The schema shows that the ID is a number.
The name is a string
and the email address is also a string.
Choose Create to create the schema.
When you choose your schema from the schema registry
you can see the structure
of the event that you just created.
Once a schema is added to the registry
you can download a code binding,
which allows you to represent the event
as an object in your code.
You can take advantage of IDE features,
such as validation and auto complete.
Code bindings are also available for Java, Python
or TypeScript programming languages.
You can download bindings
from the Amazon EventBridge console
or directly from your IDE
with the AWS Toolkit plugin for IntelliJ and VS Code.
From the EventBridge console, navigate to your schema
and then choose download code bindings.
Choose the programming language you prefer,
then choose download.
This downloads the code binding to your local machine.
You can also choose to download code bindings
directly to your IDE with the AWS Toolkit.
This tutorial uses VS Code,
but you can also use IntelliJ.
Ensure you have VS Code installed
and then navigate to the VS Code marketplace
and search for AWS and install the AWS Toolkit.
You may have to restart VS Code.
Choose a profile to connect to AWS
and then set the region to the same region
that you created the schema in.
You see this icon on the left panel
when you access the AWS Explorer.
Choose schemas from the left panel,
then choose your schema, My Registry.
Open user by right clicking and choosing View Schema.
You can now use this event object in your code.
To learn more about event-driven architecture,
EventBridge schema registry and Amazon EventBridge,
head to serverlessland.com
where you'll find more content from me and my team.
I'm Talia Nassi. Thanks for tuning in.