【问题标题】:GCP EventArc trigger for Firestore doc creation limited to specific collection?用于创建 Firestore 文档的 GCP EventArc 触发器仅限于特定集合?
【发布时间】:2021-08-04 15:42:53
【问题描述】:

我在 GCP 控制台中看到,我现在可以使用 google.firestore.v1.Firestore.CreateDocument 方法在创建 Firestore 文档时创建 EventArc 触发器,但是如何仅过滤到特定集合的文档?

我认为我需要提供一个“资源名称”,但我不清楚这应该是什么,也找不到任何有关它的文档。有人有什么想法吗?

我的项目名称是ocapp,我想要触发的集合是account

【问题讨论】:

  • 我尝试过,但无法获得活动。在一个或所有集合上。我不知道我在想什么
  • 无论我如何尝试,我都无法在云运行服务上接收任何 Firestore 事件。
  • 有人成功了吗?

标签: google-cloud-platform google-cloud-firestore event-arc


【解决方案1】:

要触发 Firestore 事件,您可以使用审核日志类型和 Firestore 过滤器。

Firestore 审核日志支持的方法可以在 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

以下教程展示了如何为审核日志配置 Eventarc 触发器并使用审核日志事件:

【讨论】:

    猜你喜欢
    • 2021-06-30
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    • 2021-12-25
    • 2018-06-19
    • 2020-03-09
    • 2019-05-29
    • 2022-01-27
    相关资源
    最近更新 更多