2 回答

TA貢獻1893條經驗 獲得超10個贊
在某些時候,我使用CLI來模擬一個帳戶:
gcloud config set auth/impersonate_service_account <service account>
然后,稍后在嘗試使用應用程序默認憑據命令時,它會使用服務帳戶憑據包裝您的憑據。
gcloud auth application-default login
您最終得到的是一個如下所示的文件:
{
"delegates": [],
"service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken",
"source_credentials": {
"client_id": "123abc.apps.googleusercontent.com",
"client_secret": "XXXXXXXXX",
"refresh_token": "XXXXXXXXX",
"type": "authorized_user"
},
"type": "impersonated_service_account"
}
這似乎會導致第三方服務(如terraform)出現很多問題。
奇怪的是,Terraform只是使用Google SDK對Google進行API調用,因此它確實與Google有關。
您需要刪除模擬:
gcloud config unset auth/impersonate_service_account
然后再次運行應用程序默認憑據命令:
gcloud auth application-default login
現在,如果您檢查文件,它應該如下所示:
{
"client_id": "XXXXXXXXX",
"client_secret": "XXXXXXXXX",
"quota_project_id": "example-project",
"refresh_token": "XXXXXXXXXX",
"type": "authorized_user"
}
當我嘗試模擬帳戶時,我遇到了同樣的問題,因此我可以將Terraform命令作為服務帳戶而不是我的個人帳戶運行,但它不喜歡這樣。
編輯:重讀你的問題,聽起來你和我在同一條船上。我們希望使用服務帳戶,而無需實際下載密鑰。谷歌甚至提到這是最佳實踐。但這樣做會導致他們自己的SDK出現問題。
- 2 回答
- 0 關注
- 204 瀏覽
添加回答
舉報