google-cloud-platformgoogle-cloud-pubsubgoogle-cloud-runevent-arc

How to trigger Cloud Run from Global EventArc using pub sub


I have a cloudrun service deployed in asia-south1 region and would like to trigger it from eventarc when a message is published in pubsub.

However asia-south1 doesn't have eventarc, so I decided to create event arc trigger as location=global.

Below see below command.

    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

However it fails with below error mentioning that type should be 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

When I try to create trigger with google.cloud.audit.log.v1.written It fail with missing service name error. Please see below

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

I could not seem to find any documentation which mentions about global trigger with pubsub and cloud run. Can somebody please help me to understand how to link a pubsub based event trigger to cloud run when event arc location is global or point me to right direction?

Thanks


Solution

  • You can set the location that you want where eventarc is supported. The "issue" that you will have is you will pay for the inter-region traffic. that's all.


    As workaround, you need to know how work EventArc. it create, under the hood (but you can see that in your project) a pubsub push subscription to call your Cloud Run service at the specified URL.

    You can create manually this push subscription and wait for an eventarc availability in your region.