Create an EventBridge Rule for Logging Events in a CloudWatch Log
To test the connection between Salesforce and AWS and ensure that the event messages are received in EventBridge, add a CloudWatch log as a target of a rule. Incoming event messages from Salesforce are logged in CloudWatch. For more information, see Amazon EventBridge rules and Amazon EventBridge targets in the AWS documentation.
-
In Amazon Eventbridge, click Rules.
-
Select your event bus from the dropdown. The name of the event bus is the same as the name of the partner event source that you queried earlier. It’s in this format: aws.partner/salesforce.com/orgID/channelID“
-
In the Rules section, click Create rule.
-
Provide a name for your rule.
-
Click Next.
-
Under Event source, select AWS events or EventBridge partner events.
-
Skip the Sample event section. In Event pattern, for Event source, select EventBridge partners.
-
From the partner dropdown, select Salesforce.
-
For Event type, select All Events. The event pattern box autopopulates to this value.
-
-
The rule matches incoming events based on the defined pattern. If you want to add a filter to match a specific platform event, match events whose
detail-type
field contains the API name of the platform event, for example,Carbon_Comparison__e
. For more information about event pattern matching, see Content filtering in Amazon EventBridge event patterns in the AWS documentation.-
Under Event pattern, click Custom patterns (JSON editor).
-
In the input box, In Define pattern, select Custom pattern, and replace the pattern with this pattern.
-
-
Click Next.
-
Under Target 1, Target types, select AWS service.
-
Under Select a target, select CloudWatch log group.
-
Complete the log group path. For example:
/aws/events/mygroup/log
. -
Click Next and then Next.
-
Review the rule that you created, and then click Create rule.
To test receiving events, open the CloudWatch log.
-
Click the rule that you just created.
-
Under Targets, click the log. The CloudWatch log opens in a new tab.
-
Publish an event from Salesforce. To find out about methods for publishing an event, see Publishing Platform Events in the Platform Events Developer Guide. For example, you can use REST API to publish this
Carbon_Comparison__e
event message.Perform a POST request to this URI. In Postman, click REST > SObject > SObject Create, and replace the
:SOBJECT_API_NAME
placeholder withCarbon_Comparison__e
.Use this request body.
You get a response similar to this response. The status of
OPERATION_ENQUEUED
means that the platform event message is published asynchronously. -
Refresh the CloudWatch log stream. The received event is displayed in the log group, similar to this event.
The received event contains the payload of the Salesforce event in the detail
field. The top-level fields, such as version
and detail-type
, are EventBridge event fields. The detail-type
field contains the Salesforce event API name. In combination with the source
field, the detail-type
field identifies the fields and values that appear in the detail
field. For more information, see Amazon EventBridge events in the AWS documentation.