DEV Community

Cover image for Part 2: Activating the Event Relay in Salesforce and AWS
Sandeep Sangu
Sandeep Sangu

Posted on • Edited on

Part 2: Activating the Event Relay in Salesforce and AWS

Welcome back to our event-driven journey with Salesforce and AWS. This chapter focuses on activating the Salesforce Event Relay and connecting it with Amazon EventBridge, a key step to achieving a seamless data flow and leveraging the full capabilities of our integrated setup.

Taking a streamlined approach, we'll utilize the straightforward instructions from the official Salesforce documentation, ensuring clarity and direct access to essential steps without unecessary elaboration.

Let's continue our adventure, where we'll activate the Partner Event Source in Amazon EventBridge and kick-start the event relay in Salesforce. Ready for the next leap? Let's dive in.

  • Initial Setup: Begin by ensuring you are logged into both your Salesforce and AWS free tier consoles. This foundational step is crucial for the tasks ahead.

Before Activating:

Before associating the event bus

In acknowledgment of Salesforce’s detailed documentation, I recommend consulting their official guide to activate the Partner Event Source in Amazon EventBridge. Visit Activate the Partner Event Source in Amazon EventBridge for comprehensive steps on completing the setup, including the event bus association. Successfully doing so will change the event source status to Active.

Following the association of the partner event source with the event bus, your setup should resemble the snapshot below:

After associating the partner event source with the event bus

Continuing with the momentum, initiating the event relay is our next objective. Salesforce offers clear instructions that facilitate this process effortlessly. For a step-by-step guide, consult Start the Event Relay.

After starting the event relay

Completing these tasks marks a significant milestone in our journey, successfully concluding the initial half of our adventure.

Setting Up Our Log Group 📝

Let's quickly set up a log group in AWS CloudWatch. This log group will play a crucial role later on. I’ve named mine SF-Employee-CDC-Logs as a nod to its purpose. For this demo, I named it with a specific focus. I encourage you to choose a name that aligns with your setup, capturing the essence of your demo.

EventBridge Rule

As we delve deeper into integrating Salesforce with AWS, our next pivotal task is to establish an EventBridge rule 🛠️. This rule is designed to capture events from any Salesforce custom object enabled for Change Data Capture (CDC), relaying them through our configured AWS partner event source and into the CloudWatch log group we've prepared.

Salesforce's documentation offers a clear, step-by-step guide for both setting up this EventBridge rule and ensuring it's correctly linked to the event bus and the designated log group. For comprehensive instructions on configuring the rule to capture and store events as intended, please refer to Create an EventBridge Rule for Logging Events in a CloudWatch Log. This resource provides all the details you need to successfully navigate this critical step, ensuring a seamless flow of data within our integrated cloud environment.

In customizing our integration, I've assigned the rule a specific identifier, SF-CDC-EmployeeChange-Rule, to clearly reflect its function. Feel inspired to select a name that aligns with what you’ve established so far in this demo, truly making it your own.

Adding a Personal Touch from Step 6 Onwards:

Following Salesforce's guide closely until step 5 was helpful, but from step 6, I introduced some personal tweaks to better fit our scenario:

  • Event Source: Select Others to broaden our event capture scope.
  • Sample Event: Skipping this is optional, though it may simplify your setup.
  • Creation Method: Use the Custom pattern option in the JSON editor for more control.
  • Event Pattern: Craft your event capture criteria with this JSON structure:
{
  "source": ["aws.partner/salesforce.com/xxxxxxxxxxxxxxxxA0/0YLIS000000KyjB4AS"],
  "detail-type": ["Employee__ChangeEvent"]
}
Enter fullscreen mode Exit fullscreen mode

⚠️ Important Note: The ID in the event source is intentionally obscured for privacy. Please ensure you substitute this with the complete ID of your event bus, which was generated when you associated/activated the partner event source.

Event Pattern

Continue by clicking 'Next', guiding you to the 'Select target(s)' page:

  • Target 1: Within the AWS Service section, select CloudWatch log group from the dropdown.
  • Log Group: Enter the name of the log group you created earlier, SF-Employee-CDC-Logs.

Upon successfully configuring your rule, inspecting your event bus will display a setup similar to what's illustrated below, confirming that your configuration is on point and operational:

Target Screenshot

Event Bus and Rule Gist

And just like that, we're almost at the finish line 🏁! The last piece of our setup puzzle is to enable CDC on our custom object. Let's dive into that:

From the Setup page in Salesforce, use the quick find box to search for Change Data Capture. You'll see a page similar to what's shown below. From the available entities, type in the name of the custom object you created, select it, and use the arrow to move it from the available to the selected entities, then click on "Save."

CDC Enabled on Custom Object

🎉 Voila! We've now wrapped up the essential setup, ready to witness our creation spring into action.

Before we proceed, let's do a quick recap ⚡ of what we've accomplished in Part 1 and Part 2:

  • AWS and Salesforce Setup: Checked and done!
  • Within Salesforce:

    • Crafted a custom object and populated it with sample records.
    • Set up Named Credentials and CORS with the required URLs of Postman in the allowed origin list.
    • Created a channel for a change event using Postman, and added a channel member.
    • Ended Part 1 by setting up the event relay.
  • In Part 2, focusing on AWS:

    • Navigated to AWS and activated the partner event source by selecting it and clicking on "Associate with event bus," then confirmed that the status is "Active."
    • Created a log group in AWS CloudWatch.
  • Back in Salesforce to wrap up:

    • Changed the status of the Event Relay from "Stopped" to "Running."
    • Enabled CDC on the custom object to catch those changes.

With our setup complete, what's next on the horizon? 🌅

Coming Up in Part 3: Visualization with Grafana

In our grand finale, we'll turn raw data into visual insights. We'll guide you through integrating CloudWatch logs with Grafana and setting up dashboards that vividly display our event data. Get ready for a visual feast as we explore Create, Delete, and Update operations, tracing the journey of events to our log group, and finally, to Grafana for the ultimate visualization.

Stay tuned for the thrilling conclusion of our series, where data meets design! 📊🎨

Disclaimer: This series is based on my personal experiences and insights gained from various resources and documentation. The aim is to share knowledge and foster learning within the community. Any resemblance to other materials is coincidental, and I acknowledge the contributions of the broader tech community in advancing our understanding of these topics.

#CommunityContributions

Top comments (0)