Dominic
Dominic

Reputation: 725

Deploy Cloud Storage Triggers in Multi-Region Buckets

I am trying to deploy a Cloud Storage trigger by following the guide here: https://cloud.google.com/functions/docs/tutorials/storage#object_finalize

I want to listen for any finalization in my default "us multi-region" bucket. Unfortunately, when I try to deploy the function trigger via gcloud cli as described in the link above:

gcloud functions deploy **** \
--gen2 \
--region=us-central1 \
--project=**** \
--trigger-event-filters="type=google.cloud.storage.object.v1.finalized" \
--trigger-event-filters="bucket={my-multi-region-bucket}"

I get the following error:

INVALID_ARGUMENT: Cannot create trigger ****: 
Bucket '****' is in location 'us', but the trigger location is 'us-central1'.
The trigger must be in the same location as the bucket. 
Try redeploying and changing the trigger location to 'us'.

Upvotes: 6

Views: 1715

Answers (1)

Dominic
Dominic

Reputation: 725

I finally got it working by simply adding the --trigger-location=us as shown below:

gcloud functions deploy **** \
--gen2 \
--region=us-central1 \
--project=**** \
--trigger-event-filters="type=google.cloud.storage.object.v1.finalized" \
--trigger-event-filters="bucket={my-multi-region-bucket}" \
--trigger-location=us

Upvotes: 16

Related Questions