当试图从自身(从实例中)向Compute引擎实例添加元数据时,我遇到了一个问题。
在IAM中,我使用计算实例管理(v1)角色test-compute@test.iam.gserviceaccount.com创建了一个特定的服务帐户
在实例化VM时,我指定了前面的服务帐户:test-compute@test.iam.gserviceaccount.com
当我与ssh连接到VM时,我可以看到帐户被设置为正确的服务帐户。
gcloud config list
[core]
account = test-compute@test.iam.gserviceaccount.com
disable_usage_reporting = True
project = test-project
Your active configuration is: [default]然后,当我试图将元数据添加到VM中时(从VM本身),就会得到这个错误。
gcloud compute instances add-metadata --metadata "start=true" --zone europe-
west1-b <INSTANCE_NAME>
ERROR: (gcloud.compute.instances.add-metadata) Could not fetch resource:
- The user does not have access to service account 'test-compute@test.iam.gserviceaccount.com'. U
ser: 'test-compute@test.iam.gserviceaccount.com'. Ask a project owner to grant you the iam.service
AccountUser role on the service account发布于 2019-03-01 21:01:20
有两个可能导致此错误的问题:
计算引擎的默认服务帐户仅具有“编辑器”角色。但是,这经常会被改变,所以我指定了两个步骤来解决这个问题。
您需要关闭实例以更改实例的设置。
注意,VM实例"Cloud访问作用域“不能向您的服务帐户没有的VM实例提供权限。如果仍然有相同的错误消息,则需要将角色roles/iam.serviceAccountUser添加到您的服务帐户中。
发布于 2019-03-04 13:14:57
当我将roles/iam.serviceAccountUser添加到我的服务帐户时,它可以工作。由于用户是服务帐户(用户== ServiceAccount),所以我不明白为什么要添加这个角色?
https://stackoverflow.com/questions/54942321
复制相似问题