Search code examples
google-cloud-platformgcloudgoogle-cloud-runregiongoogle-cloud-shell

Set a default Cloud Run region? (GCP)


Whenever running a Cloud Run service on Cloud Shell:

gcloud run deploy myapp --image gcr.io/myproject-1831713/myapp

I'm always asked to input a Cloud Run region as shown below:

Please specify a region:
[1] asia-east1
[2] asia-east2
[3] asia-northeast1 [4] asia-northeast2
[5] asia-northeast3
[6] asia-south1
[7] asia-south2
[8] asia-southeast1
[9] asia-southeast2
[10] australia-southeast1
[11] australia-southeast2
[12] europe-central2 [13] europe-north1
[14] europe-west1
[15] europe-west2
[16] europe-west3
[17] europe-west4
[18] europe-west6
[19] northamerica-northeast1
[20] northamerica-northeast2
[21] southamerica-east1
[22] southamerica-west1
[23] us-central1
[24] us-east1
[25] us-east4
[26] us-west1
[27] us-west2
[28] us-west3 [29] us-west4
[30] cancel Please enter your numeric choice:

So that I'm not asked to input a Cloud Run region whenever running a Cloud Run service on Cloud Shell, is it possible to set a default Cloud Run region? If possible, how can I do this?


Solution

  • Yes, it's possible to set a default Cloud Run region with this command below so that you're not asked to input a Cloud Run region whenever running a Cloud Run service on Cloud Shell:

    gcloud config set run/region <region>
    

    So, for example, run this command below to set the default Cloud Run region "asia-northeast1" :

    gcloud config set run/region asia-northeast1
    

    In addition, you can check your default Cloud Run region with this command below:

    gcloud config get run/region
    

    Then, this is the result:

    Your active configuration is: [cloudshell-5343] asia-northeast1

    And, you can check all configurations including your default Cloud Run region with this command below:

    gcloud config list
    

    Then, this is the result:

    [accessibility]
    screen_reader = True
    [component_manager]
    disable_update_check = True
    [compute]
    gce_metadata_read_timeout_sec = 30
    [core]
    account = [email protected]
    disable_usage_reporting = True
    project = myproject-383171
    [metrics]
    environment = devshell
    [run]
    region = asia-northeast1

    Your active configuration is: [cloudshell-5343]

    In addition again, you can unset your default Cloud Run region with this command below:

    gcloud config unset run/region
    

    Then, check your default Cloud Run region:

    gcloud config get run/region
    

    Then, this is the result:

    Your active configuration is: [cloudshell-5343] (unset)