AWS EventBridge for dummies

Rina Andria
2 min readMar 18, 2021
Photo by Pixabay from Pexels

From its name AWS EventBridge, I was scared, really scared to discover what lies beneath the second word.

I was expecting something complex, something hard to understand, something unusual.

The first time I put my hands on the AWS documentation though, my breaths started to be steady, then my mind started to reconstruct, and at the end, my eyes lightened up.

Here is the simplest/the most basic thing I got from it:

Let’s imagine something simple:

It’s our everyday topic the “weather”. There are constant and endless weather events we get every second, minute, or hour. Depending on if it’s rainy, sunny, or windy though, we need to know different parameters like wind speed, temperature, humidity, or precipitation. So everyone will react differently according to those pieces of information. Some will be happy with rainy weather, others will welcome any sun.

Above in notifyWeather, a custom event is being created and sent to the EventBridge. You should specify the Source of the event (here WeatherData), the DetailType of the event (what kind of message do you want to convey?), and eventually, the Detail which corresponds to the message (payload) you want to send to the event bus.

Then somewhere else we expect to receive WeatherData. How do we handle this data? If it’s sunny or rainy in our case. With the code above, we specify the handler which will be processed whenever we receive an event of source WeatherData, and type Sunny or Rainy. We don’t care about the other types in this specific case. We could have reacted as well in case it snows for instance.

In case you use AWS services, don’t forget to give you service the right on events:PutEvents actions.

And in our handler, we do what we need to do. Here we are happy because it rains, and disappointed because the sun will heat up again. For others, it might not be the case :). So this is just one example of handler. You can have many of those.

So that's a simple example of a use case for EventBridge: it connects Applications through events (Even driven architecture).

Don’t take it for granted though! This example is just a tiny part of the possibilities the AWS EventBridge can do. It can do complex things. You can connect it to Saas applications that act as event sources. You can create more complex rules than what I gave in this example, and target HTTP API endpoint instead of AWS services. For more details, I encourage you to read the AWS documentation which provides much more information than here. Good luck!

--

--