[英]Firestore created document Eventarc audit log methods are inconsistent
创建新的 Firestore 文档时,我正在尝试调用服务。 使用 Cloud Functions v1,这很简单并且效果很好( https://firebase.google.com/docs/functions/firestore-events )。 随着通过 Eventarc 触发 Cloud Functions v2/Cloud Run,我正在努力获得类似甚至一致的行为,并且觉得我错过了一些东西。
我的期望是让我们获得与 v1 函数相同的行为,我需要记录一个审核日志,其中服务名称为firestore.googleapis.com
和方法名称为google.firestore.v1.Firestore.CreateDocument
(根据https ://cloud.google.com/eventarc/docs/reference/supported-events#cloud-firestore )来创建。 我正在为文档创建编写审计日志,但没有一致的行为。
如果我在 GCP 或 Firebase 控制台中创建新文档,则会生成服务名称为firestore.googleapis.com
和方法名称为google.firestore.v1.Firestore.Write
的审核日志记录。
如果我使用 Firestore 客户端 SDK(使用 Android 测试)创建一个新文档,则会生成一个服务名称为firestore.googleapis.com
和方法名称为google.firestore.v1.Firestore.Write
的审核日志记录。
如果我使用 Firestore Admin SDK 创建一个新文档(使用"@google-cloud/firestore
和 firebase firebase-admin
for Node 和cloud.google.com/go/firestore
for Go...所有相同的行为进行测试),一个生成服务名称为firestore.googleapis.com
和方法名称为google.firestore.v1.Firestore.Commit
的审计日志记录。
// JS implementation...similar implementation for Go
const {Firestore} = require('@google-cloud/firestore');
...
const db = new Firestore({...});
const collection = db.collection('users');
const res = await collection.add({});
google.firestore.v1.Firestore.CreateDocument
创建一个新文档,一个审计日志记录的服务名称为firestore.googleapis.com
和方法名称为curl --request \
POST 'https://firestore.googleapis.com/v1/projects/MY_PROJECT/databases/(default)/documents/users' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer MY_TOKEN' \
--data '{"fields":{}}'
我的目标是具有类似于 v1 函数的行为,我可以可靠地响应文档创建。
以上都不一定是错误的,但没有一致的行为并不是很好。 我不觉得我做错了什么,但显然也没有做对什么。 我遗漏了什么,或者我应该纠正我的 Eventarc mental model 吗?
来自https://cloud.google.com/functions/docs/calling/cloud-firestore (最近为 2022 年 9 月 7 日):
Cloud Functions(第 2 代)目前不支持 Cloud Firestore 触发器。
来自https://cloud.google.com/functions/docs/calling (最近为 2022 年 9 月 7 日):
注意:Eventarc 目前不支持来自 Firestore、Google Analytics for Firebase 或 Firebase 身份验证的直接事件。 使用 Cloud Functions(第一代)来使用这些事件。
如果您想要 Eventarc 的 v1 行为,目前不支持。 继续使用 v1 函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.