It seems I have to install gcloud every time I want to use it. Is there a way to install it and just use which account I want to use it with?
Env: Mac OSX 12.4
Thank you.
In order to install Cloud SDK on a Mac OS system, you could follow the Install the Google Cloud CLI quickstart. Here is a list of simplified steps taken from the quickstart:
python3 -V
from a command line)uname -m
from a command line.
./google-cloud-sdk/install.sh
./google-cloud-sdk/bin/gcloud init
Use the gcloud init command to perform several common gcloud CLI setup tasks. These include authorizing the gcloud CLI to access Google Cloud using your user account credentials and setting up the default configuration.
gcloud init
To continue, you must log in. Would you like to log in (Y/n)? Y
Pick cloud project to use: [1] [my-project-1] [2] [my-project-2] ... Please enter your numeric choice:
gcloud has now been configured! You can use [gcloud config] to change more gcloud settings. Your active configuration is: [default]
Now the gcloud SDK tools are successfully installed on your macOS, and you can use it to manage all the resources from CLI.
Then, if you want to have multiple configurations (such as account, project-ID, etc) and switch between them, you could check the Managing gcloud CLI configurations documentation:
The single default configuration is suitable for many use cases. However, you can also create additional configurations and switch between them as required using gcloud config configurations activate.
To create a configuration, run gcloud config configurations create
:
gcloud config configurations create [NAME]
You must activate the new configuration after creation in order to use it.
Only one of your multiple configurations can be active at a given time. The active configuration is the configuration whose properties will govern the behavior of the gcloud CLI.
To activate a new configuration or switch to a new active configuration, run: gcloud config configurations activate
:
gcloud config configurations activate [NAME]
There are also a few useful videos on YouTube about these topics: