Reputation: 51
Google recently released the new Eventarc API trigger for e.g Cloud run. I had the idea to build one trigger for my cloud storage like: new file in bucket → trigger cloud run (with audit log trigger)
cloud_run_path: ...run.app/api/v1/data-fetcher bucket_id: test-bucket
I just created the trigger with the following command and it is successful:
gcloud beta eventarc triggers create test-event-trigger \
--location=europe-west1 \
--destination-run-service=test-event-data-fetcher \
--destination-run-path=/api/v1/data-fetcher \
--destination-run-region=europe-west1 \
--matching-criteria="type=google.cloud.audit.log.v1.written" \
--matching-criteria="serviceName=storage.googleapis.com" \
--matching-criteria="methodName=storage.objects.create" \
--matching-criteria="resourceName=projects/_/buckets/test-bucket" \
--service-account=$PROJECT_NR-compute@developer.gserviceaccount.com
The problem is, I don't want the trigger to look for new files in all buckets in the project, just for one specific bucket (e.g test-bucket). I tested now several options with different writings (with :, =~, ...), but the trigger don't accept these. Maybe you can help me out with the syntax or show me way how its possible to create a Trigger for one specific bucket in my project? Like this it's not working...
Upvotes: 5
Views: 1522
Reputation: 15018
You can achieve this by using the matching criteria type=google.cloud.pubsub.topic.v1.messagePublished
which subscribes to a particular Pubsub topic instead of all storage events from the audit logs. Then, configure a storage trigger on test-bucket
to publish to the topic generated for this Eventarc trigger.
Edit: my configuration is below.
gcloud beta eventarc triggers create <my_trigger> \
--destination-run-service=<my service> \
--destination-run-region=us-central1 \
--destination-run-path="/<my_endpoint>" \
--matching-criteria="type=google.cloud.pubsub.topic.v1.messagePublished" \
--service-account=${PROJECT_NUMBER}[email protected]
then run
gcloud beta eventarc triggers describe <my_trigger>
to get the name of the generated topic, and conigure your storage triggers to publish to that topic.
Upvotes: 0
Reputation: 15266
As of this time (2020-11) wild cards and prefix matching are not supported in the configuration of the trigger. It appears that this feature has been heavily requested and is apparently known to the product manager at Google that owns this product area. There is no public/committed date for when such a feature will be added. If this is a blocker for you, contact your local Google rep and they can schedule a call with the Product Manager to discuss the road map.
Upvotes: 4