[英]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.