使用gcloud CLI创建Eventarc触发器时遇location属性缺失错误求助
Eventarc触发器创建失败的问题解决
两个核心问题导致报错
缺少触发器的Location参数
错误提示里的location是Eventarc触发器本身的部署区域,和Cloud Run服务的区域是两个不同的配置项。你当前只指定了Cloud Run服务的--destination-run-region,但必须给Eventarc触发器本身添加--location参数(建议和Cloud Run服务区域保持一致)。路径模式的键使用错误
针对Cloud Storage对象的路径过滤,应该用object作为路径模式的键,而非bucket。且你已经通过--event-filters="bucket=bucket-name"指定了目标桶,不需要在路径模式里重复桶的完整资源路径。
修正后的完整命令
gcloud eventarc triggers create bq-trigger-test \ --location=asia-southeast1 \ --destination-run-service=bigquery-upload \ --destination-run-region=asia-southeast1 \ --event-filters="type=google.cloud.storage.object.v1.finalized" \ --event-filters="bucket=bucket-name" \ --event-filters-path-pattern="object=**/filename.json"
额外优化
如果不想每次创建触发器都手动指定--location,可以设置默认配置:
gcloud config set eventarc/location asia-southeast1
内容的提问来源于stack exchange,提问作者unacorn
相关产品推荐
相关产品推荐

