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.

  1. In Amazon Eventbridge, click Rules.

  2. 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

  3. In the Rules section, click Create rule.

  4. Provide a name for your rule.

  5. Click Next.

  6. Under Event source, select AWS events or EventBridge partner events.

  7. Skip the Sample event section. In Event pattern, for Event source, select EventBridge partners.

    1. From the partner dropdown, select Salesforce.

    2. For Event type, select All Events. The event pattern box autopopulates to this value.

  8. 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.

    1. Under Event pattern, click Custom patterns (JSON editor).

    2. In the input box, In Define pattern, select Custom pattern, and replace the pattern with this pattern.

  9. Click Next.

  10. Under Target 1, Target types, select AWS service.

  11. Under Select a target, select CloudWatch log group.

  12. Complete the log group path. For example: /aws/events/mygroup/log.

  13. Click Next and then Next.

  14. Review the rule that you created, and then click Create rule.

To test receiving events, open the CloudWatch log.

  1. Click the rule that you just created.

  2. Under Targets, click the log. The CloudWatch log opens in a new tab.

  3. 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 with Carbon_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.

  4. 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.