當有多個帳戶時,可利用glcoud config set去切換

查詢帳號

gcloud auth list
  Credentialed Accounts
ACTIVE  ACCOUNT
        account1@123.com
*       account2@123.com

To set the active account, run:
    $ gcloud config set account `ACCOUNT`

這表示有兩個帳號,目前是在account2的帳號底下

如果要切換,就下

gcloud config set account account1@123.com

切換專案

切換玩帳戶後,下指令查詢該帳號底下有哪些專案

gcloud projects list
PROJECT_ID        NAME              PROJECT_NUMBER
yoyot-aaa-0123456  My First Project  123455432123

不切換的話,會一直留存在上一個帳戶的專案底下,要是沒有提供權限,會出現

ERROR: (gcloud.compute.instances.list) Some requests did not succeed:
 - Required 'compute.zones.list' permission for 'projects/ooo-xxxxx-987123

切換專案是使用gcloud config set project {PROJECT_ID}

gcloud config set project yoyot-aaa-0123456