DEV Community

Noriko Yamamoto
Noriko Yamamoto

Posted on

4

How to switch multiple accounts for GCP gcloud command

If you have two accounts below:


STEP 1. create configuration set for account1

% gcloud config configurations create account1
Created [account1].
Activated [account1].
Enter fullscreen mode Exit fullscreen mode
% gcloud config set project hoge-fuga-123
Updated property [core/project].
Enter fullscreen mode Exit fullscreen mode
% gcloud config set account sample@account1.sample
Updated property [core/account].
Enter fullscreen mode Exit fullscreen mode

STEP 2. create configuration set for account2

% gcloud config configurations create account2
Created [account2].
Activated [account2].
Enter fullscreen mode Exit fullscreen mode
% gcloud config set project hoge-fuga-456
Updated property [core/project].
Enter fullscreen mode Exit fullscreen mode
% gcloud config set account sample@account2.sample
Updated property [core/account].
Enter fullscreen mode Exit fullscreen mode

STEP 3. switch to account1 and check config

% gcloud config configurations activate account1
Activated [account1].
Enter fullscreen mode Exit fullscreen mode
% gcloud config list
[core]
account = sample@account1.sample
disable_usage_reporting = False
project = hoge-fuga-123

Your active configuration is: [account1]
Enter fullscreen mode Exit fullscreen mode

STEP 4. switch to account2 and check config

% gcloud config configurations activate account2
Activated [account2].
Enter fullscreen mode Exit fullscreen mode
% gcloud config list
[core]
account = sample@account2.sample
disable_usage_reporting = False
project = hoge-fuga-456

Your active configuration is: [account2]
Enter fullscreen mode Exit fullscreen mode

GCP original reference page: https://cloud.google.com/sdk/gcloud/reference/config/configurations/

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs