GCP EventArc trigger for Firestore doc creation limited to specific collection?

Viewed 489

I see in the GCP console that I can now create EventArc triggers on Firestore document creation using the method google.firestore.v1.Firestore.CreateDocument but how do I filter to only documents of a specific collection?

I assume I need to provide a 'Resource name' but I'm unclear what this should be and can't find any documentation about it. Anyone have any ideas?

My project name is ocapp and the collection I'm wanting triggers for is account.

1 Answers

To trigger on Firestore events, you can use the Audit Log type and filter for Firestore.

Supported methods for Firestore Audit Logs can be found in https://github.com/googleapis/google-cloudevents/blob/main/AUDIT_CATALOG.md#cloud-firestore

gcloud eventarc triggers create firestore-trigger \
   --destination-run-service=helloworld-firestore \
   --destination-run-region=us-central1 \
   --event-filters="type=google.cloud.audit.log.v1.written" \
   --event-filters="serviceName=firestore.googleapis.com" \
   --event-filters="methodName=google.firestore.v1.Firestore.Write" \
   --service-account=sample-service-account@PROJECT_ID.iam.gserviceaccount.com

The following tutorials show how to configure an Eventarc trigger for an Audit Log and consume the audit log event:

Related