Building an event-driven architecture using DynamoDB and EventBridge!
Journey: 📊 Community Builder 📊
Subject matter: Building on AWS
Task: Building an event-driven architecture using DynamoDB and EventBridge!
Using the 6 Pillars of the AWS Well-Architected Framework, Performance Efficiency, Reliability, and Sustainability will be achieved in this build.
This week, I built an event-driven architecture using DynamoDB Streams and EventBridge Pipes.
This project is quite simple but demonstrates how AWS services work together to provide a working solution when notifications are required on specific database conditions.
Resource credit: This architecture was created using guidance from Helio Tarnowski on Medium Here.
What did I use to build this environment?
- AWS Management Console
What is built?
- A DynamoDB Table
- An Eventbridge pipe
- An SNS Topic
In this task, I built an event-driven architecture using three services; DynamoDB, SNS, and EventBridge.
I created a DynamoDB Table with a Partition Key and a Sort Key.
After the table had been created successfully, I turned on the DynamoDB stream option with a ’new image’ type so all changes to my table were captured.
I then switched over to SNS, created a new standard Topic, and subscribed a temporary email address to it.
Once I had confirmed the subscription in my temporary email, I moved over to EventBridge and created a new EB Pipe.
I configured this with a DynamoDB source of my payments database, filtered with a specific Event pattern to monitor for unauthorised payments, and pointed the target to be my SNS Topic.
To test my setup, I returned to my DynamoDB table and manually created a new item using JSON, the first of which was Authorised.
As expected, no email was received as the EventBridge Pipe is listening for unauthorised payments.
I created a new item in my DB table, again with JSON but this time set the authorisation parameter as ‘Not Authorised’.
After checking my email, I noticed that I had a new item waiting. My SNS Topic had delivered an email to me reporting an unauthorised payment in my DynamoDB Table.
This event-driven architecture showed how we can create scalable and resilient applications with only a few AWS products and services.
Next time?
I could broaden my configuration here in the future by doing the following:
- Form the project using IaC and use Terraform to create the environment.
- Create an API with a Cognito Authoriser and schedule PUT items from the Postman platform.
Some of the highlights…
DynamoDB creation:
DynamoDB Stream:
SNS Subscription:
Confirmed Sub:
EventBridge Pipe creation:
EventBridge Pipe filter:
EventBridge Pipe running:
DynamoDB Table authorised item:
DynamoDB Table unauthorised item:
DynamoDB Table display:
Checking for emails:
My interpretation of the architecture:
I hope you have enjoyed the article!