Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

huangapple go评论69阅读模式
英文:

Eventarc to trigger Cloud Run by Firestore document creation event

问题

我正在尝试为当新的Firestore文档被添加时触发Cloud Run时设置基本的Eventarc触发器。

我按照下面截图所示的方式设置了它(区域:全球;资源:任何)。然后我在Firestore中创建了一个新文档(数据库位置:europe-west3)。但是在europe-north1的Cloud Run服务并没有被触发;而且在触发器监控中也没有关于事件的任何信息显示(请参见截图)。

我做错了什么?

Firestore日志:
Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

触发器详细信息:
Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

英文:

I am trying to set up a basic Eventarc trigger for triggering Cloud Run when a new Firestore document is added.

I set it up as depicted in the screenshot below (region: global; resource: any). Then I create a new document in Firestore (database location: europe-west3). The Cloud Run service in europe-north1 does not get triggered; moreover, no information about the event shows up in the trigger monitoring (see the screenshot).

What am I doing wrong?

Firestore log:
Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

Trigger details:
Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

答案1

得分: 1

以下是翻译好的部分:

"It took me a day, but here is the thing. To use Eventarc for Firestore events, you need to enable Compute Engine API audit logging, NOT the Firestore/Datastore API. You can do that in IAM and admin -> Audit logs.

It does not seem self-evident to me. It would be nice if the documentation had that explicitly about the Firestore vs. Compute Engine APIs.

Here is the configuration that works:
Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

英文:

It took me a day, but here is the thing. To use Eventarc for Firestore events, you need to enable Compute Engine API audit logging, NOT the Firestore/Datastore API. You can do that in IAM and admin -> Audit logs.

It does not seem self-evident to me. It would be nice if the documentation had that explicitly about the Firestore vs. Compute Engine APIs.

Here is the configuration that works:
Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

Eventarc 触发 Cloud Run 通过 Firestore 文档创建事件

答案2

得分: 0

根据文档,在向Firestore数据库添加文档后,有一个更适合触发Cloud Run服务的事件示例:

gcloud eventarc triggers create your-trigger \
  --location ${REGION} --service-account your-sa-email \
  --destination-run-service your-service  \
  --event-filters type=google.cloud.audit.log.v1.written \
  --event-filters methodName=google.firestore.v1.Firestore.CreateDocument \
  --event-filters serviceName=firestore.googleapis.com

在这个示例中,我使用了一个事件筛选器,其中 methodName=google.firestore.v1.Firestore.CreateDocument

英文:

According to the documentation, there is a more adapted event to trigger a Cloud Run service after adding a document in the Firestore database, example :

gcloud eventarc triggers create your-trigger \
  --location ${REGION} --service-account your-sa-email \
  --destination-run-service your-service  \
  --event-filters type=google.cloud.audit.log.v1.written \
  --event-filters methodName=google.firestore.v1.Firestore.CreateDocument \
  --event-filters serviceName=firestore.googleapis.com

In this example I used an event filter with methodName=google.firestore.v1.Firestore.CreateDocument

huangapple
  • 本文由 发表于 2023年3月7日 04:11:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75655417.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定