First event bus and targets

In this module, you will create a custom EventBridge event bus, Orders, and an EventBridge rule, OrderDevRule, which matches all events sent to the Orders event bus and sends the events to a CloudWatch Logs log group, /aws/events/orders. See the diagram below:

Simple Event Bus

The technique of logging all events to CloudWatch Logs is useful when implementing EventBridge rules.

Step 1: Create a custom event bus

  1. Open the AWS Management Console for EventBridge in a new tab or window, so you can keep this step-by-step guide open.

  2. On the EventBridge homepage, open the left hand navigation.

    EventBridge Console

  3. Select Event buses from the left-hand menu.

  4. Click Create event bus.

    Create Bus

  5. Name the event bus Orders.

  6. Leave the Permissions blank.

    Create Bus

  7. Click Create.

Step 2: Set up Amazon CloudWatch target (for development work)

A simple way to test, and get rapid feedback for, the rules you create for your event bus is to use Amazon CloudWatch as a target. We will create a rule for the Orders bus that will act as a “catch-all” for every event passed to the bus, irrespective of source.

  1. From the left-hand menu, select Rules.

  2. From the Event bus dropdown, select the Orders event bus.

  3. Click Create rule New rule

  4. On the Create rule page

    • add OrdersDevRule as the Name of the rule
    • add Catchall rule for development purposes for Description
  5. Under Define pattern

    • Choose Event pattern
    • Under Event matching pattern, select Pre-defined pattern by service and the All Events from the Source provider dropdown.

    Take this opportunity to familiarize yourself with some the options available for AWS services, there are many examples of pre-defined patterns that are used for service events.

    You’ll be creating your own custom event patterns in the next section.

    Create Bus

  6. Ensure that you have selected Orders from the Select event bus panel

    Select event bus panel

  7. Select your rule target:

    • From the Target dropdown, select CloudWatch log group
    • Name your log group /aws/events/ orders

    CloudWatch log group

  8. Leave the Tags blank.

    Create Bus

  9. Click Create.

Step 3: Test your dev rule

  1. Open the Event Generator for EventBridge in a new tab or window, so you can keep this step-by-step guide open.

  2. Make sure that the Event Generator is populated with the following (if you clicked the link above then you should see this pre-populated):

    • Event Bus selected to Orders
    • Source should be
    • In the Detail Type add Order Notification
    • JSON payload for the Detail Template should be:
      "category": "lab-supplies",
      "value": 415,
      "location": "eu-west"
  3. Click Publish.

    CloudWatch log group

  4. Open the AWS Management Console for CloudWatch in a new tab or window, so you can keep this step-by-step guide open.

  5. Choose Log groups in the left navigation and select the /aws/events/orders log group.

    CloudWatch log group entry

  6. Select the log stream from the list of Log streams.

    CloudWatch log group streams

  7. Expand the log event from the list of Log events and verify the log event send from Event Generator.

    CloudWatch log group entry

Step 4: Review event structure

Take note of the event structure and data! A sample event is provided below for your reference. The event is comprised of envelope attributes (version, id, source, detail-type, etc) and custom data in the detail attribute. It is very important to match the nested event attribute structure when writing EventBridge Rules.

In the following sections, you will use event data to implement EventBridge custom rules to route events. Due to the OrdersDevRule that you created in this section, all events to the Orders event bus will be sent to CloudWatch Logs, which you can use to view sample data in order to implement and troubleshoot rules matching logic.

    "version": "0",
    "id": "c04cc8c1-283c-425e-8cf6-878bbc67a628",
    "detail-type": "Order Notification",
    "source": "",
    "account": "123456789012",
    "time": "2020-02-20T23:10:29Z",
    "region": "us-west-2",
    "resources": [],
    "detail": {
        "category": "lab-supplies",
        "value": 415,
        "location": "eu-west"

CONGRATULATIONS! Your have configured your first target, let’s configure some more targets for our Order event bus. In the next section, Working with EventBridge Rules, you will look more closely at how to use the event pattern matching and integration with other services.