Background

My employer recently set me out on a project to figure out a way to move configuration data from one legacy Rails app to another different Rails API, with disparate data models. Of course, there are many ways to do this, but as someone who has been the victim (and instigator of) unnecessary service-oriented architecture design, we wanted to avoid standing up a separate service to achieve these goals. Also, my team is currently tasked with overhauling our SOA to something smaller, so anything that could begin to reduce that scope was a good thing.

After some digging into Gregor Hohpe and Bobby Woolf’s Enterprise Integration Patterns, we realized what we needed was a message bus. Now, we could implement this ourselves, but the overhead cost would be too great.

This is when I found out about AWS EventBridge, a relatively new service on AWS executing standard event bus interactions.

This seemed like a good choice for our purposes (we use AWS for many things, custom events cost $1.00/million events sent) and we set ourselves out on a POC. It took little time to figure out the ins and outs and our integration ending up being pretty straightforward, but I initially had trouble finding any blog posts or readings about utilizing EventBridge with two existing large web applications. Most of what I could find online was, say, connecting a partner integration of Salesforce and storing data to DynamoDB, or triggering Cloudwatch events via the default EventBridge, etc.

Hopefully to save you some headache of staring at AWS SDK documentation for hours on end, I’ve set up a sample repo to use as a guide to follow along.


Prereqs:

  • This won’t be much use for you unless you have an AWS account. You’ll need your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY stored somewhere in your environment in order to establish connections to EventBridge. The AWS SDK loads these automagically from your ~/.aws/credentials file so no need for much setup there on the application. (See AWS documentation for more info.)
  • Later versions of this will hopefully be on Docker and include Localstack for local development with AWS services and some out-of-the-box necessities, but for the moment, you’ll also need some standard-ish Rails needs to run locally: Postgres, Node for front-end assets, Ruby 2.7, bundler.
  • To follow along with example code, see the repo here: https://github.com/CoolJorcz/eventbridge_sample
  • As a general overview of Event-Driven Architectures, this 2019 NY AWS Summit video was very useful to me.

#eventbridge #event-driven-architecture #aws #rails #integration

Using AWS EventBridge to Clean Up Your Service-Oriented Architecture: An Overview
9.45 GEEK