How can I specify a region for the Cloud Storage buckets used by Cloud Build for a Cloud Run deployment?

As you mention, Cloud Build creates a bucket or buckets with multi region because when creating the service in Cloud Run, there are only added the needed flags and arguments to deploy the service.

The documentation for the command gcloud builds submit mentions the following for the flag --gcs-source-staging-dir:


A directory in Google Cloud Storage to copy the source used for staging the build. If the specified bucket does not exist, Cloud Build will create one. If you don't set this field, gs://[PROJECT_ID]_cloudbuild/source is used.

As this flag is not set, the bucket is created in multi-region and in us. This behavior also applies for the flag --gcs-log-dir.

Now the necessary steps to use the bucket in the dual-region, region or multi-region you want is using a cloudbuild.yaml and using the flag --gcs-source-staging-dir. You can do the following:

  1. Create a bucket in the region, dual-region or multi-region you may want. For example I created a bucket called "example-bucket" in australia-southeast1.
  2. Create a cloudbuild.yaml file. This is necessary to store the artifacts of the build in the bucket you want as mentioned here. An example is as follows:
- name: ''
    - 'run'
    - 'deploy'
    - 'cloudrunservice'
    - '--image'
    - ''
    - '--region'
    - '--platform'
    - 'managed'
    - '--allow-unauthenticated'
    location: 'gs://example-bucket'
    paths: ['*']
  1. Finally you could run the following command:
gcloud builds submit --gcs-source-staging-dir="gs://example-bucket/cloudbuild-custom" --config cloudbuild.yaml

The steps mentioned before can adapted to your script. Please give a try :) and you will see that even if the Cloud Run service is deployed in Asia, Europe or US, the bucket specified before can be in another location.