Create a bus to route messages

An Eventarc Advanced bus lets you centralize, monitor, and trace the flow of messages through your system, and acts as a router. It receives events from a message source or published by a provider, and evaluates them according to an enrollment. An enrollment identifies a subscription to a particular bus, and defines the matching criteria for messages, causing them to be routed accordingly. For more information, see Create an enrollment to receive events.

A bus can be used by event providers and destinations in your project or in other projects. For more information, see Project layouts.

Required roles

An Identity and Access Management (IAM) role contains a set of permissions that lets you perform specific actions on Google Cloud resources. The following roles and permissions are required when creating a bus to route messages:

  • To get the permission that you need to create a bus, ask your administrator to grant you either the Eventarc Admin (roles/eventarc.admin) or the Eventarc Message Bus Admin (roles/eventarc.messageBusAdmin) IAM role on your bus project. These predefined roles contain the eventarc.messageBuses.create permission, which is required to create a bus.
  • To get the permission that you need to use a bus, ask your administrator to grant you the Eventarc Message Bus User (roles/eventarc.messageBusUser) IAM role on your bus project. This predefined role contains the eventarc.buses.use permission, which is required to use a bus.
  • To create a pipeline and an enrollment, additional permissions are required. For more information, see the required roles when creating an enrollment.

For more information about granting roles, see Manage access. You might also be able to get these permissions with custom roles or other predefined roles.

Create a bus

You can create a bus in the Google Cloud console or by using the gcloud CLI.

Console

  1. In the Google Cloud console, go to the Eventarc > Bus page.

    Go to Bus

  2. Click Create bus.

  3. On the Create a bus page, do the following:

    1. Enter a Bus name. This is the ID for your bus.
    2. Optional: Enter a Bus display name which is displayed on the Bus details page.
    3. In the Region list, select a supported region to deploy your bus in.
    4. For Encryption, accept the default Google-managed encryption key or select Cloud KMS key. For more information, see Use customer-managed encryption keys (CMEK).
    5. If you select Cloud KMS key, do the following:

      1. In the Key type list, select a method to manage your keys.

        You can manage your keys manually or you can use Autokey which lets you generate key rings and keys on-demand. If the Cloud KMS with Autokey option is disabled, it isn't yet integrated with the current resource type.

      2. In the Select a Cloud KMS key, select a key.

        Note that you must select a region before you can view your customer-managed keys.

      3. Optional: To manually enter the resource name of the key, in the Select a customer-managed key list, click Enter key manually, and enter the key name in the specified format.

      4. If prompted, grant the cloudkms.cryptoKeyEncrypterDecrypter role to the Eventarc Service Agent.

    6. Optional: To add a message source, click Add source.

      1. In the Add message source pane, for the Google API message provider, accept the default of google-api-source or enter a different source name.
      2. Click Create.

        This enables the automatic collection of events coming directly from Google sources.

        Note that only events from resources in the same Google Cloud project as the bus are published. For more information, see Publish events from Google sources.

    7. Optional: To add labels, click Add label. Labels are key-value pairs that help you organize your Google Cloud resources. For more information, see What are labels?

  4. Click Create.

gcloud

  1. Open a terminal.

  2. Create a bus by using the gcloud beta eventarc message-buses create command.

    gcloud beta eventarc message-buses create BUS_NAME \
        --location=REGION
    

    Replace the following:

    • BUS_NAME: the ID or fully qualified identifier of the bus
    • REGION: a supported location for the bus

      Alternatively, you can set the Google Cloud CLI location property:

      gcloud config set eventarc/location REGION
      

    Optional: You can also use the following flags:

    • --async to return from the command immediately, without waiting for the operation in progress to complete.
    • --crypto-key to specify the fully qualified name of a customer-managed encryption key; if unspecified, Google-managed keys are used.
    • --logging-config to configure the logging level which must be one of the following: NONE, DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY.

Delete a bus

You can delete a bus in the Google Cloud console or by using the gcloud CLI.

Console

  1. In the Google Cloud console, go to the Eventarc > Bus page.

    Go to Bus

  2. Click the name of the bus that you want to delete.

    The Bus details page opens.

  3. Click Delete.

  4. When prompted to delete the bus, to acknowledge that any message sources configured to use the bus will no longer be able to, select the Do you want to proceed? checkbox.

  5. To confirm the deletion, enter Delete.

  6. Click Delete.

gcloud

  1. Open a terminal.

  2. Delete a bus by using the gcloud beta eventarc message-buses delete command.

    gcloud beta eventarc message-buses delete BUS_NAME \
        --location=REGION
    

    Replace the following:

    • BUS_NAME: the ID or fully qualified identifier of the bus
    • REGION: the supported location for the bus

What's next