如何使用 pub sub 从 Global EventArc 触发 Cloud 运行

How to trigger Cloud Run from Global EventArc using pub sub

我在 asia-south1 区域部署了一个云运行 服务,我想在 pubsub 中发布消息时从 eventarc 触发它。

但是 asia-south1 没有 eventarc,所以我决定创建事件弧触发器作为 location=global。

下面请看下面的命令。

    gcloud eventarc triggers create pubsub-trigger-new-auction-notification \
    --location=global \
    --destination-run-service=notification \
    --destination-run-path=/notify/bidder/auction \
    --destination-run-region=asia-south1 \
    --event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \
    --transport-topic=projects/<my-project_id>/topics/newauction-notify \
    --service-account=cloud-run-pubsub-invoker@<my-project_id>.iam.gserviceaccount.com

但是它失败并出现以下错误,提到该类型应该是 google.cloud.audit.log.v1.written

ERROR: (gcloud.eventarc.triggers.create) INVALID_ARGUMENT: The request was invalid: [INVALID_ARGUMENT] The request was invalid: invalid value for attribute 'type' in trigger.event_filters: only type "google.cloud.audit.log.v1.written" is allowed in global location

当我尝试使用 google.cloud.audit.log.v1.written 创建触发器时 它因缺少服务名称错误而失败。请看下面

ERROR: (gcloud.eventarc.triggers.create) INVALID_ARGUMENT: The request was invalid: [INVALID_ARGUMENT] The request was invalid: missing required attribute "serviceName" in trigger.event_filters

我似乎找不到任何提到使用 pubsub 和云进行全局触发的文档 运行。 有人可以帮助我了解如何 link 当事件弧位置是全局的或指向正确的方向时,如何 link 基于 pubsub 的事件触发到云 运行 吗?

谢谢

您可以设置支持 eventarc 的位置。您将遇到的“问题”是您将为区域间流量付费。就这些了。


作为解决方法,您需要了解 EventArc 的工作原理。它在幕后创建(但您可以在您的项目中看到)一个 pubsub 推送订阅,以在指定的 URL.

调用您的 Cloud 运行 服务

您可以手动创建此推送订阅并等待您所在地区的 eventarc 可用性。