Is there a way to activate a Google cloud service account non-globally?
I have such requirement to manipulate different services on different projects. Hence I need to activate multiple service accounts at the same time to do those jobs. Those service accounts' roles are well controlled so there's no way to make a "admin"-like account to run on all projects. So I'm wondering if there's a way to activate one service account only in current process or some isolated environment without impact on global
gcloud info settings. Any suggestion is appreciated.
You can use
glcoud config configurationsand setup multiple account configurations to select from.
Then use the
--configuration=configuration_nameto select which one to use:
gcloud compute instances list --configuration=NAME
gcloud initand select
Create a new configuration.
You can change the default configuration with
gcloud config configurations activate NAME.
I wrote an article that documents gcloud configurations:
You can also activate service account credentials which will then be part of
gcloud config configurations.
gcloud auth activate-service-account email@example.com --key-file=test_google_account.json