CLI gcloud Configuration

This blog is about gcloud configuration setup and management, recapped from my daily work, they are useful especially the api_endpoint_overrides so I don’t need to run lengthy API call counterpart.

List gcloud configuration

You may have multiple gcloud configuration entities:

1
2
3
4
5
6
$ gcloud config configurations list

NAME IS_ACTIVE ACCOUNT PROJECT COMPUTE_DEFAULT_ZONE COMPUTE_DEFAULT_REGION
env-139 False chengdol@example.com chengdol-demo
env-149 True chengdol@example.com chengdol-demo
default False chengdol@example.com chengdol-demo

Activate gcloud configuration

To activate target:

1
gcloud config configurations activate env-149

Describe activated gcloud configuration

Check activate gcloud config:

1
2
3
4
5
6
7
8
9
10
11
12
$ gcloud config list

[api_endpoint_overrides]
sql = https://env-149.sandbox.googleapis.com/
[billing]
quota_project = other-project
[core]
account = chengdol@example.com
disable_usage_reporting = True
project = chengdol-demo

Your active configuration is: [env-149]

Or using:

1
2
3
4
5
6
7
8
9
10
11
$ gcloud config configurations describe env-149
is_active: true
name: env-149
properties:
api_endpoint_overrides:
sql: https://env-149.sandbox.googleapis.com/
billing:
quota_project: other-project
core:
account: chengdol@example.com
project: chengdol-demo
  • api_endpoint_overrides: it enables you to run gcloud sql against the overidden endpoint (e.g development backend).

  • quota_project: for quota control, you can update it by

1
gcloud config set billing/quota_project other-project

Delete gcloud configuration

1
gcloud config configurations delete env-149
0%