Google Cloud 如何验证默认服务帐户?

How Google Cloud authenticates default service accounts?

我想知道 Google 如何在用户的项目中验证 default service accounts

例如,我的项目中有用于计算的默认服务帐户,但它没有关联的模拟或身份验证方法(没有 IAM 策略绑定,如 iam.ServiceAccounts.getAccessToken,也没有密钥):

$ gcloud iam service-accounts list
DISPLAY NAME                            EMAIL                                               DISABLED
Compute Engine default service account  502923505097-compute@developer.gserviceaccount.com  False

$ gcloud iam service-accounts get-iam-policy 502923505097-compute@developer.gserviceaccount.com
etag: ACAB 

有一些绑定是从项目级别继承的。例如,有 Compute Engine Service Agent 的绑定:

$ gcloud projects get-iam-policy  cedar-lexicon-312307
bindings:
- members:
  - serviceAccount:service-502923505097@compute-system.iam.gserviceaccount.com
  role: roles/compute.serviceAgent

我是否正确理解了 Compute Engine Service Agent 有权模拟我项目中的 any 服务帐户并用于模拟计算的默认服务帐户? Google 服务是否有任何其他方式(可能对用户隐藏)来模拟默认服务帐户?

您可以在documentation中看到服务代理的角色。它是 Google 托管服务帐户,授予您的项目,让 google 自动化服务与您的项目交互。您可以删除这些服务帐户服务代理的权限,以删除 Google 平台产品与您的项目交互的权限。使用风险自负!

如果你想回滚你的测试,你可以尝试禁用然后启用相关的API。

您还可以使用正确的角色手动将服务帐户服务代理电子邮件添加到您的项目。