Google 最近发布了新的 Eventarc API 触发器,例如 Cloud run。我的想法是为我的云存储构建一个触发器,例如:存储桶中的新文件?触发云运行(带审计日志触发器)
cloud_run_path: ...run.app/api/v1/data-fetcher bucket_id: test-bucket
我刚刚使用以下命令创建了触发器,并且成功了:
gcloud beta eventarc triggers create test-event-trigger \
--location=europe-west1 \
--destination-run-service=test-event-data-fetcher \
--destination-run-path=/api/v1/data-fetcher \
--destination-run-region=europe-west1 \
--matching-criteria="type=google.cloud.audit.log.v1.written" \
--matching-criteria="serviceName=storage.googleapis.com" \
--matching-criteria="methodName=storage.objects.create" \
--matching-criteria="resourceName=projects/_/buckets/test-bucket" \
--service-account=$PROJECT_NR-compute@developer.gserviceaccount.com
Run Code Online (Sandbox Code Playgroud)
问题是,我不希望触发器在项目的所有存储桶中查找新文件,只为一个特定的存储桶(例如 test-bucket)查找。我现在用不同的文字测试了几个选项(用 :, =~, ...),但触发器不接受这些。也许您可以帮助我解决语法问题或向我展示如何为我的项目中的一个特定存储桶创建触发器?像这样它不起作用......
sdk google-cloud-storage google-cloud-platform google-cloud-run event-arc
我尝试为用户删除(Firebase Auth)创建一个触发器,该触发器应该调用我的 Cloud Run 实例,但似乎即使在 10 分钟后它也不会触发。这就是我创建触发器的方式:
gcloud eventarc triggers create on-delete-user \
--event-filters="methodName=google.firebase.auth.user.v1.deleted" \
--event-filters="serviceName=identitytoolkit.googleapis.com" \
--event-filters="type=google.cloud.audit.log.v1.written" \
--destination-run-service=grpc-v1-dev \
--destination-run-path=/api.v1.DeleteUserEvent \
--service-account user@projectId.iam.gserviceaccount.com \
--location europe-west4 \
--project projectId \
--format json
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
更新:我还尝试使用我在日志中看到的方法名称。
gcloud eventarc triggers create on-delete-user-2 \
--event-filters="type=google.cloud.audit.log.v1.written" \
--event-filters="serviceName=identitytoolkit.googleapis.com" \
--event-filters="methodName=google.cloud.identitytoolkit.v1.AccountManagementService.DeleteAccount" \
--destination-run-service=grpc-v1-dev \
--destination-run-path=/api.v1.DeleteUserEvent \
--service-account user@projectId.iam.gserviceaccount.com \
--location europe-west4 \
--project projectId \
--format json
Run Code Online (Sandbox Code Playgroud)
更新2:
我也尝试使用控制台创建它,但仍然没有事件。
UPDATE3:我确实从日志中获取事件google.cloud.identitytoolkit.v1.AccountManagementService.DeleteAccount,并且我的云实例接收到调用,但我收到的数据与此处的模型无关。
我在 GCP 控制台中看到,现在可以使用该方法在 Firestore 文档创建时创建 EventArc 触发器,google.firestore.v1.Firestore.CreateDocument但如何仅筛选特定集合的文档?
我认为我需要提供“资源名称”,但我不清楚这应该是什么,也找不到任何有关它的文档。有人有主意吗?
我的项目名称是ocapp,我想要触发器的集合是account。
我想为 GCS 对象创建创建一个 eventarc 触发器。根据 Eventarc 文档,这应该使用直接 GCS 触发器。我可以像这样创建它,但我不知道在哪里放置存储桶名称:
resource "google_eventarc_trigger" "upload" {
name = "upload"
location = "europe-west1"
matching_criteria {
attribute = "type"
value = "google.cloud.storage.object.v1.finalized"
}
destination {
workflow = google_workflows_workflow.process_file.id
}
service_account = google_service_account.workflow.email
}
Run Code Online (Sandbox Code Playgroud)
当我运行此示例时,出现以下错误:
Error: Error creating Trigger: googleapi: Error 400: The request was invalid: The request was invalid: missing required attribute "bucket" in trigger.event_filters
Run Code Online (Sandbox Code Playgroud) google-cloud-storage google-cloud-platform terraform event-arc
我正在尝试在 google cloud run 项目上设置一个 EventArc 触发器,以便在新文件上传到特定存储桶时运行。
问题是,如果我选择,我只能让它工作 any resource,即上传到我的任何存储桶的文件都会运行触发器。但是,我只希望它为上传到特定存储桶的文件运行。
如果我选择“特定资源”,它会要求我输入“完整资源名称”。但是似乎没有关于如何格式化存储桶名称以使其工作的文档。我已经尝试了存储桶名称,projects/_/buckets/my_bucket_name但除非我选择“任何资源”,否则触发器永远不会运行。
任何想法如何给它命名桶名称,以便这将起作用?
google-cloud-storage google-cloud-platform google-cloud-run event-arc