我刚接触GCP。我有一个具有以下角色的服务帐户: 我为此创建了一个json密钥,并用它来认证gcloud客户端。该客户端正在该服务帐户上该项目的实例上运行。我似乎没有任何权限:
# gcloud auth activate-service-account cloudbreak@**********-lab.iam.gserviceaccount.com --key-file **********-lab-804c90ab0a14.json
# gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
* cloudbreak@**********-lab.iam.gserviceaccount.com
To set the active account, run:
$ gcloud config set account `ACCOUNT`
# gcloud compute regions list
ERROR: (gcloud.compute.regions.list) Some requests did not succeed:
- Required 'compute.regions.list' permission for 'projects/**********-lab'
# gcloud projects get-iam-policy **********-lab
ERROR: (gcloud.projects.get-iam-policy) User [cloudbreak@**********-lab.iam.gserviceaccount.com] does not
have permission to access project [**********-lab:getIamPolicy] (or it may not exist): The caller does n
ot have permission
我想念什么?
答案 0 :(得分:1)
GCP中存在一个长期存在的错误,在该错误中,删除服务帐户并以相同的名称重新创建它可能导致无法识别其权限的问题。您描述的行为(创建具有相同权限的新服务帐户并看到其工作)与该错误的症状相符。
答案 1 :(得分:0)
我通过创建一个新的服务帐户(具有相同的角色)并改用该帐户来解决了这一问题。我不知道对方会发生什么
答案 2 :(得分:0)
要修复服务帐户,您可以按照https://cloud.google.com/iam/docs/understanding-service-accounts中的提示进行操作。
发生异常行为的原因如下:It is possible to delete a service account and then create a new service account with the same name. If you reuse the name of a deleted service account, it may result in unexpected behavior. [...] If you create a new service account with the same name as a recently deleted service account, the old bindings may still exist
要解决此问题,请执行以下操作: