DEV Community

Cover image for Momento added as an Amazon EventBridge API destination!
Rishti Gupta for Momento

Posted on • Originally published at gomomento.com

Momento added as an Amazon EventBridge API destination!

Building a real-time weather update system with Momento, Amazon EventBridge, and DynamoDB

If you’re like many of us who use DynamoDB as a durable data store, you might have noticed that getting real-time updates when data changes can be challenging. DynamoDB streams gives you a way to monitor events in your database, but it can take a lot of code and infrastructure to handle them efficiently. Now, with Momento’s new partnership with Amazon EventBridge makes real-time updates easier than ever.

Yes, you heard it right—Momento is now officially an API Destination Partner with Amazon EventBridge! To celebrate this milestone, we’ve built a real-time weather update system using Amazon EventBridge, Momento, and DynamoDB. Let’s dive in and explore how it works!

Project overview

Our goal is to build a robust system that tracks weather information for various locations and deliver real-time updates. We are going to use a powerful trio—DynamoDB for storage, Amazon EventBridge for event handling, and Momento for caching and notifications.

Our sample application is designed to store weather information for different geographic locations in a DynamoDB table. Whenever there’s an update in the weather for a specific location, this change is immediately captured and propagated using a series of interconnected AWS services.

High-level architecture

To visualize how everything fits together, consider the architecture below.

High-Level-Arch

When a weather record is updated in DynamoDB, a DynamoDB stream triggers an event that travels through EventBridge. This event is then routed to two endpoints in the Momento HTTP API, which are configured as API destinations in EventBridge: Momento Cache and Momento Topic. The cache can enhance performance and reduce costs by reducing database load, while the topic facilitates real-time notifications that you can deliver to other components in your application, or directly to browsers and mobile devices, without managing any of your own infrastructure.

Getting started with the demo

Check out our GitHub repository to quickly set up and run the web application.

If you’re interested in understanding the CDK code used to deploy the necessary resources, be sure to check out the dedicated page for an in-depth explanation.

Application Workflow

  • Open the Web Application: Launch the web application at http://localhost:5173. You’ll see a form designed to input weather data.

  • Enter Weather Data: Fill in the form with weather details for a specific location and submit it. This data is then stored in the DynamoDB table.

Enter_Weather_Data

  • Data Written to DynamoDB: The weather data is securely stored in DynamoDB. Immediately, DynamoDB streams triggers an event that is sent to EventBridge.

Data_In_DynamoDb

  • EventBridge in Action: EventBridge processes the event triggered by the DynamoDB stream and forwards it to both the Momento Cache and Momento Topic. This is done using EventBridge Pipes, which are connected to the stream as the source and the Momento HTTP API destinations as the targets. The API destinations for Momento Cache and Topic are configured within EventBridge, enabling direct routing of the event to these endpoints.

  • Caching with Momento: The weather data is cached in Momento, reducing the load on DynamoDB for future reads and improving performance.

Caching_with_Momento

  • Real-Time Notifications: Meanwhile, Momento Topics broadcasts the event, simulating real-time notifications for any interested parties.

Topics_With_Momento

  • Delete Weather Record: You can also delete a weather record, which will be reflected in the cache and notifications.

Delete_Weather_Record

  • Updated Momento Cache: The deleted record will also be removed from Momento Cache.

Updated_Momento_Cache

  • Remove Event in Momento Topics: Finally, a REMOVE event will appear in Momento Topic.

Remove_Event_Topics

Wrapping Up

And there you have it—a real-time weather update system that seamlessly integrates Amazon EventBridge, Momento, and DynamoDB. By following this example, you’ve learned how to set up a write-through cache, reduce database load, and keep your users informed with real-time updates.

Ready to build your own weather update system? For more insights and resources, get started with Momento today or check out our docs to learn how to start building on Momento.

Additional Resources

Integrate Amazon DynamoDB Streams with Momento, via AWS EventBridge.

Top comments (0)