Skip to content

Instantly share code, notes, and snippets.

@ashwinrs
Created August 3, 2020 21:12
Show Gist options
  • Save ashwinrs/54bc9a7df974670201d88a0ed5dfba08 to your computer and use it in GitHub Desktop.
Save ashwinrs/54bc9a7df974670201d88a0ed5dfba08 to your computer and use it in GitHub Desktop.
How to run CLI command as a Google service account
# download service account key (this will require ServiceAccount Key Admin role)
gcloud iam service-accounts keys create ./key.json --iam-account <service_account>
# Set following env var to point to the service account key file
export GOOGLE_APPLICATION_CREDENTIALS=./key.json
# Keep in mind that changing gcloud auth by the below command, will not work as only "gcloud" commands use it,
# gcloud auth activate-service-account <service_account> --key-file=./key.json
# gcloud auth list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment