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 theeventarc.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 theeventarc.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 following ways:
- In the Google Cloud console
- By using the Google Cloud CLI in either your terminal or Cloud Shell
- By sending a request to the Eventarc API
Console
-
In the Google Cloud console, go to the Eventarc > Buspage.
-
Click Create bus.
-
On the Create a buspage, do the following:
- Enter a Bus name. This is the ID for your bus.
- Optional: Enter a Bus display namewhich is displayed on the Bus detailspage.
- In the Regionlist, select a supported region to deploy your bus in.
- In the Log severitylist, select the minimum severity for events
described in log entries. The default is None. For more information,
see
LogSeverity
. - For Encryption, accept the default Google-managed encryption keyor select Cloud KMS key. For more information, see Use customer-managed encryption keys (CMEK) .
-
If you select Cloud KMS key, do the following:
-
In the Key typelist, 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 Autokeyoption is disabled, it isn't yet integrated with the current resource type.
-
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.
-
Optional: To manually enter the resource name of the key, in the Select a customer-managed keylist, click Enter key manually, and enter the key name in the specified format.
-
If prompted, grant the
cloudkms.cryptoKeyEncrypterDecrypter
role to the Eventarc Service Agent .
-
-
Optional: To add a message source, click Add source.
- In the Add message sourcepane, for the Google API message
provider, accept the default of
google-api-source
or enter a different source name. -
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 .
- In the Add message sourcepane, for the Google API message
provider, accept the default of
-
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?
-
Click Create.
gcloud
-
Open a terminal.
-
Create a bus by using the
gcloud eventarc message-buses create
command.gcloud 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 busAlternatively, 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-owned and managed keys are used. -
--logging-config
to configure the minimum severity for events described in log entries. Must be one of the following:NONE
,DEBUG
,INFO
,NOTICE
,WARNING
,ERROR
,CRITICAL
,ALERT
,EMERGENCY
. The default isNONE
. For more information, seeLogSeverity
.
-
REST API
To create a bus, use the projects.locations.messageBuses.create
method.
Before using any of the request data, make the following replacements:
-
BUS_NAME
: the display name of your bus—for example,my_bus
. -
LABEL_KEY
andLABEL_VALUE
: optional. A map of label key and value pairs that help you organize your Google Cloud resources. For more information, see What are labels? -
ANNOTATION_KEY
andANNOTATION_VALUE
: optional. A map of annotation key and value pairs of free-form text. You can use them to attach arbitrary information associated with the resource. For more information, see Annotations . -
ENCRYPT_KEY
: optional. A Cloud KMS key that the bus should use for data encryption in the formatprojects/ PROJECT_NAME /locations/ LOCATION /keyRings/ RING_NAME /cryptoKeys/ KEY_NAME
. For more information, see Use customer-managed encryption keys . -
PROJECT_ID
: your Google Cloud project ID. -
LOCATION
: the region in which to create the bus—for example,us-central1
. -
LOG_SEVERITY
: optional. The minimum severity of the event described in a log entry. One of:NONE
,DEBUG
,INFO
,NOTICE
,WARNING
,ERROR
,CRITICAL
,ALERT
,EMERGENCY
. The default isNONE
. For more information, seeLogSeverity
.
Request JSON body:
{ "display_name": " BUS_NAME ", "labels": {" LABEL_KEY ":" LABEL_VALUE "}, "annotations": {" ANNOTATION_KEY ":" ANNOTATION_VALUE "}, "cryptoKeyName": " ENCRYPT_KEY ", "loggingConfig": {"logSeverity":" LOG_SEVERITY "} }
To send your request, expand one of these options:
If successful, the response body contains a newly created instance of Operation
:
{ "name": "projects/ PROJECT_ID /locations/ LOCATION /operations/ OPERATION_ID ", "metadata": { "@type": "type.googleapis.com/google.cloud.eventarc.v1.OperationMetadata", "createTime": "2024-01-25T17:17:45.782370139Z", "target": "projects/ PROJECT_ID /locations/ LOCATION /messageBuses/ BUS_NAME ", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
Delete a bus
You can delete a bus in the following ways:
- In the Google Cloud console
- By using the gcloud CLI in either your terminal or Cloud Shell
- By sending a request to the Eventarc API
Console
-
In the Google Cloud console, go to the Eventarc > Buspage.
The Bus detailspage opens.
-
Click Delete.
-
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.
-
To confirm the deletion, enter
Delete
. -
Click Delete.
gcloud
-
Open a terminal.
-
Delete a bus by using the
gcloud eventarc message-buses delete
command.gcloud 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
-
REST API
To delete a bus, use the projects.locations.messageBuses.delete
method.
Before using any of the request data, make the following replacements:
-
PROJECT_ID
: your Google Cloud project ID. -
LOCATION
: the region in which the bus is created—for example,us-central1
. -
BUS_NAME
: the name of the bus you want to delete.
To send your request, expand one of these options:
If successful, the response body contains a newly created instance of Operation
:
{ "name": "projects/ PROJECT_ID /locations/ LOCATION /operations/ OPERATION_ID ", "metadata": { "@type": "type.googleapis.com/google.cloud.eventarc.v1.OperationMetadata", "createTime": "2024-01-25T17:17:45.782370139Z", "target": "projects/ PROJECT_ID /locations/ LOCATION /messageBuses/ BUS_NAME ", "verb": "delete", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }