You can manage triggers using either the Google Cloud console or the Google Cloud CLI in either your terminal or Cloud Shell. You can also manage triggers through the Eventarc API.
List triggers
You can list, filter, and sort through your triggers in all locations.
In the Google Cloud console, go to the Eventarc Triggers page.
This lists all the triggers in your project for all locations, and includes details such as the trigger name, region, event provider, destination, and event type.
To filter your triggers by a specific property:
- Click the Filter box.
- From the list of Properties, select an option to filter the triggers by—for example, Name or Event channel.
You can select a single property or use the logical operator
OR
to add more properties to filter by.To sort your triggers, click
Sort beside the appropriate column heading.Only some columns are sortable—for example, Name, Region, or Event channel.
gcloud eventarc triggers list --location=-
This command lists your trigger name, type, destination, and status in all locations.
To list triggers in a given project and location, use the
projects.locations.triggers.list
method.
Before using any of the request data, make the following replacements:
: your Google Cloud project ID.PROJECT_ID
: the region in which the triggers are created—for example,LOCATION us-central1
.
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers"
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers" | Select-Object -Expand Content
If successful, the response body contains instances of
Trigger
and the response should be similar to the following:
{ "triggers": [ { "name": "projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME ", "uid": "d700773a-698b-47b2-a712-2ee10b690062", "createTime": "2022-12-06T22:44:04.744001514Z", "updateTime": "2022-12-06T22:44:09.116459550Z", "eventFilters": [ { "attribute": "type", "value": "google.cloud.pubsub.topic.v1.messagePublished" } ], "serviceAccount": "SERVICE_ACCOUNT_NAME @PROJECT_ID .iam.gserviceaccount.com", "destination": { "workflow": "projects/PROJECT_ID /locations/LOCATION /workflows/WORKFLOW_NAME " }, "transport": { "pubsub": { "topic": "projects/PROJECT_ID /topics/TOPIC_ID ", "subscription": "projects/PROJECT_ID /subscriptions/SUBSCRIPTION_ID " } } }, { object (Trigger) } ], "nextPageToken": string, "unreachable": [ string ] }
Describe a trigger
You can describe a trigger in a specific location.
In the Google Cloud console, go to the Eventarc Triggers page.
From the list of triggers, click the trigger you want to know the details about.
The Trigger details page displays the details of the trigger such as name, region, event provider, event type, event data content type, and destination.
gcloud eventarc triggers describeTRIGGER \ --location=LOCATION
Replace the following:
TRIGGER
: the ID of the trigger or a fully qualified identifier.LOCATION
: the location of the Eventarc trigger.
This command returns information about the trigger that is similar to the following:
createTime: '2023-03-16T13:40:44.889670204Z'
destination:
cloudRun:
path: /
region: us-central1
service: hello
eventDataContentType: application/protobuf
eventFilters:
- attribute: serviceName
value: cloudscheduler.googleapis.com
- attribute: methodName
value: google.cloud.scheduler.v1.CloudScheduler.DeleteJob
- attribute: type
value: google.cloud.audit.log.v1.written
name: projects/project-name/locations/us-central1/triggers/name-of-trigger
serviceAccount: project-number-compute@developer.gserviceaccount.com
transport:
pubsub:
subscription: projects/project-name/subscriptions/eventarc-us-central1-name-of-trigger-sub-034
topic: projects/project-name/topics/eventarc-us-central1-name-of-trigger-931
To describe a trigger in a given project and location, use the
projects.locations.triggers.get
method.
Before using any of the request data, make the following replacements:
: the name of the trigger you want to describe.TRIGGER_NAME
: your Google Cloud project ID.PROJECT_ID
: the region in which the trigger is created—for example,LOCATION us-central1
.
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME " | Select-Object -Expand Content
If successful, the response body contains an instance of
Trigger
similar to the following:
{ "name": "projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME ", "uid": "d700773a-698b-47b2-a712-2ee10b690062", "createTime": "2022-12-06T22:44:04.744001514Z", "updateTime": "2022-12-06T22:44:09.116459550Z", "eventFilters": [ { "attribute": "type", "value": "google.cloud.pubsub.topic.v1.messagePublished" } ], "serviceAccount": "SERVICE_ACCOUNT_NAME @PROJECT_ID .iam.gserviceaccount.com", "destination": { "workflow": "projects/PROJECT_ID /locations/LOCATION /workflows/WORKFLOW_NAME " }, "transport": { "pubsub": { "topic": "projects/PROJECT_ID /topics/TOPIC_ID ", "subscription": "projects/PROJECT_ID /subscriptions/SUBSCRIPTION_ID " } } }
If the condition of the trigger indicates an issue with the Pub/Sub topic, refer to Trigger is not delivering events.
Update a trigger
You can update a trigger for Cloud Run, Google Kubernetes Engine (GKE), and Workflows destinations. Depending on the destination, specific fields can be updated.
In the Google Cloud console, go to the Eventarc Triggers page.
From the list of triggers, click the trigger you want to know the details about.
On the Trigger details page, click
Edit.Edit fields as required and click Save.
Note that you can't update any unavailable fields such as the Event provider and Event destination. For more information about the fields, see the Console instructions for a specific provider, event type, and destination.
gcloud eventarc triggers updateTRIGGER \ --location=LOCATION \ --event-filters=NEW_EVENT_FILTERS \ --service-account=NEW_SERVICE_ACCOUNT \ --destination-run-region=NEW_REGION \ --destination-run-service=NEW_SERVICE \ --destination-run-path=NEW_PATH \ --event-data-content-type="NEW_EVENT_DATA_TYPE "
Replace the following:
TRIGGER
: the ID of the trigger or a fully qualified identifier.LOCATION
: the location of the Eventarc trigger.
You can update any of the following:
NEW_EVENT_FILTERS
: the filter used to configure the event routing of the trigger; for example,methodName=storage.objects.create
can be updated tomethodName=storage.objects.delete
. Note that after a trigger is created, thetype
event filter can't be changed. For a different event type, you must create a new trigger.NEW_SERVICE_ACCOUNT
: the Identity and Access Management (IAM) service account email associated with the trigger.NEW_REGION
: the region in which the destination Cloud Run service can be found.NEW_SERVICE
: the name of the Cloud Run service that receives the events for the trigger.NEW_PATH
: the relative path on the destination Cloud Run service to which the events for the trigger should be sent.NEW_EVENT_DATA_TYPE
: the encoding of the event payload; depending on the event provider, this can beapplication/json
orapplication/protobuf
.
For example, to update the service account for a trigger:
gcloud eventarc triggers update my-cloud-run-trigger \
--service-account=new-serviceaccount@${PROJECT_ID}.iam.gserviceaccount.com
This command updates the service account of a trigger named
my-cloud-run-trigger
to
new-serviceaccount@PROJECT_ID.iam.gserviceaccount.com
.
Note that this section also applies to the public endpoints of private and public services running in a GKE cluster.
gcloud eventarc triggers updateTRIGGER \ --location=LOCATION \ --destination-gke-namespace=NEW_NAMESPACE \ --destination-gke-service=NEW_SERVICE \ --destination-gke-path=NEW_PATH \ --event-data-content-type="NEW_EVENT_DATA_TYPE "
Replace the following:
TRIGGER
: the ID of the trigger or a fully qualified identifier.LOCATION
: the location of the Eventarc trigger.
You can update any of the following:
NEW_NAMESPACE
: the namespace in which the destination GKE service is running.NEW_SERVICE
: the name of the GKE service that receives the events for the trigger.NEW_PATH
: the relative path on the destination GKE service to which the events for the trigger should be sent.NEW_EVENT_DATA_TYPE
: the encoding of the event payload; depending on the event provider, this can beapplication/json
orapplication/protobuf
.
For example, to update the event receiver service for a trigger:
gcloud eventarc triggers update my-gke-trigger \
--destination-gke-service=helloworld-events
This command updates the event receiver service for a trigger named
my-gke-trigger
to a GKE service named
helloworld-events
.
gcloud eventarc triggers updateTRIGGER \ --location=LOCATION \ --event-filters=NEW_EVENT_FILTERS \ --service-account=NEW_SERVICE_ACCOUNT \ --destination-workflow=NEW_DESTINATION_WORKFLOW \ --destination-workflow-location=NEW_DESTINATION_WORKFLOW_LOCATION \ --event-data-content-type="NEW_EVENT_DATA_TYPE "
Replace the following:
TRIGGER
: the ID of the trigger or a fully qualified identifier.LOCATION
: the location of the Eventarc trigger.
You can update any of the following:
NEW_EVENT_FILTERS
: the filter used to configure the event routing of the trigger; for example,methodName=storage.objects.create
can be updated tomethodName=storage.objects.delete
. Note that after a trigger is created, thetype
event filter can't be changed. For a different event type, you must create a new trigger.NEW_SERVICE_ACCOUNT
: the Identity and Access Management (IAM) service account email associated with the trigger.NEW_DESTINATION_WORKFLOW
: the ID of the deployed workflow that receives the events from the trigger.NEW_DESTINATION_WORKFLOW_LOCATION
: the location in which the destination workflow is deployed.NEW_EVENT_DATA_TYPE
: the encoding of the event payload; depending on the event provider, this can beapplication/json
orapplication/protobuf
.
For example, to update the service account for a trigger:
gcloud eventarc triggers update my-workflows-trigger \
--service-account=new-serviceaccount@${PROJECT_ID}.iam.gserviceaccount.com
This command updates the service account of a trigger named
my-workflows-trigger
to
new-serviceaccount@PROJECT_ID.iam.gserviceaccount.com
.
To update an existing trigger, use the
projects.locations.triggers.patch
method and optionally use the updateMask
query parameter to specify a list
of fields to be updated.
Before using any of the request data, make the following replacements:
: the name of the trigger you want to update.TRIGGER_NAME
: your Google Cloud project ID.PROJECT_ID
: the region in which the trigger is created—for example,LOCATION us-central1
.
: optional. The Identity and Access Management (IAM) service account email associated with the trigger.SERVICE_ACCOUNT @PROJECT_ID .iam.gserviceaccount.com
: optional. Specifies the target where the event should be sent to and contains an instance ofDESTINATION Destination
. For example:{"destination": {"workflow": "projects/my-project/locations/us-central1/workflows/my-first-workflow"}}
or
{"destination": {"cloudRun": {"service": "hello-world", "region": "us-central1"}}}
: optional. The event attributes to filter on. Only updating the method type for Cloud Audit Logs triggers is supported. For example:EVENT_FILTER {"eventFilters": [{"attribute": "methodName", "value": "storage.buckets.create"}, {"attribute": "type", "value": "google.cloud.audit.log.v1.written"}, {"attribute": "serviceName", "value": "storage.googleapis.com"}]}
Note that you can't update method types for GKE destinations.
: optional. The encoding of the event payload; depending on the event provider, this can beCONTENT_TYPE application/json
orapplication/protobuf
.
: optional. A comma-separated list of fields to be updated. If not provided, all provided fields in the request are updated. For example:UPDATE_FIELDS serviceAccount,destination
Request JSON body:
{ "serviceAccount": "SERVICE_ACCOUNT @PROJECT_ID .iam.gserviceaccount.com", "destination":DESTINATION , "eventFilters"EVENT_FILTER , "eventDataContentType": "CONTENT_TYPE " }
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "serviceAccount": "SERVICE_ACCOUNT @PROJECT_ID .iam.gserviceaccount.com", "destination":DESTINATION , "eventFilters"EVENT_FILTER , "eventDataContentType": "CONTENT_TYPE " } EOF
Then execute the following command to send your REST request:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME ?updateMask="UPDATE_FIELDS ""
PowerShell (Windows)
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "serviceAccount": "SERVICE_ACCOUNT @PROJECT_ID .iam.gserviceaccount.com", "destination":DESTINATION , "eventFilters"EVENT_FILTER , "eventDataContentType": "CONTENT_TYPE " } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME ?updateMask="UPDATE_FIELDS "" | Select-Object -Expand Content
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 /triggers/TRIGGER_NAME ", "verb": "update", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
If the value of "done"
is false
, the operation
is still in progress.
Delete a trigger
You can delete a trigger.
In the Google Cloud console, go to the Eventarc Triggers page.
Select the trigger and click
Delete.
gcloud eventarc triggers deleteTRIGGER
Replace TRIGGER
with the ID of the trigger or a
fully qualified identifier.
To delete a trigger with a specified name, use the
projects.locations.triggers.delete
method.
Before using any of the request data, make the following replacements:
: your Google Cloud project ID.PROJECT_ID
: the region in which the trigger is created—for example,LOCATION us-central1
.
: the name of the trigger you want to delete.TRIGGER_NAME
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://eventarc.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME " | Select-Object -Expand Content
If successful, the response body contains an 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-24T17:53:52.834876290Z", "target": "projects/PROJECT_ID /locations/LOCATION /triggers/TRIGGER_NAME ", "verb": "delete", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
If the value of "done"
is false
, the operation
is still in progress.