How to set service key file for a single invocation of “gcloud” utility?
Clash Royale CLAN TAG#URR8PPP
How to set service key file for a single invocation of “gcloud” utility?
Is there a way to set a custom service key file for a single invocation of "gcloud" tool without running gcloud auth activate-service-account
?
gcloud auth activate-service-account
Similar to the related "gsutil" tool where this can be easily done using -o
option:gsutil -o Credentials:gs_service_key_file=path/to/credentials_file.json arg1 arg2 ...
-o
gsutil -o Credentials:gs_service_key_file=path/to/credentials_file.json arg1 arg2 ...
1 Answer
1
I've not tried this but, it appears, yes:
https://cloud.google.com/sdk/gcloud/reference/
gcloud --account="..."
gcloud --account="..."
You can authenticate multiple service accounts using gcloud auth activate-service-account
and you can enumerate the list with gcloud auth list. You would then switch commands between them using the
account` flag.
gcloud auth activate-service-account
gcloud auth list. You would then switch commands between them using the
Until your question, I'd always done this rather tediously through reconfiguring gcloud config set account ...
, so thanks for helping me learn something new!
gcloud config set account ...
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thanks. This solution is not exactly what I was looking for, because it needs pre-configured set of accounts, but it is better than nothing.
– mechatroner
Aug 14 at 16:08