Google cloud platform 启用GCP cloudresourcemanager gcloud config joe。bloggs@googlemail.com帐户与GCP项目所有者角色joe不匹配。bloggs@gmail.com

Google cloud platform 启用GCP cloudresourcemanager gcloud config joe。bloggs@googlemail.com帐户与GCP项目所有者角色joe不匹配。bloggs@gmail.com,google-cloud-platform,gcloud,google-cloud-iam,Google Cloud Platform,Gcloud,Google Cloud Iam,正在尝试运行: gcloud services enable cloudresourcemanager.googleapis.com —project=$GOOGLE_CLOUD_PROJECT 我得到授权错误: Enabling the Cloud Resource Manager API for project xxxxxxxxx... ERROR: (gcloud.services.enable) User [joe.bloggs@googlemail.com] does not hav

正在尝试运行:

gcloud services enable cloudresourcemanager.googleapis.com —project=$GOOGLE_CLOUD_PROJECT
我得到授权错误:

Enabling the Cloud Resource Manager API for project xxxxxxxxx... ERROR: (gcloud.services.enable) User [joe.bloggs@googlemail.com] does not have permission to access project [xxxxxxxxx] (or it may not exist): Service '—project=xxxxxxxxx' not found or permission denied.

当我检查GCP策略疑难解答时,它显示我在项目xxxxxxxxx中具有所有者角色。不过,您可以在GCP控制台中看到我的电子邮件地址joe。bloggs@gmail.com但在我的gcloud配置中是joe。bloggs@googlemail.com. 我曾尝试在gcloud config中将其更改为gmail.com,在project owner角色中将其更改为googlemail.com,但似乎无法更改。

我知道用于登录gcloud的gmail帐户有错误,请尝试使用命令验证gcloud中使用的帐户,然后,您可以使用该命令从gcloud中的所有acocont注销,然后尝试使用正确的帐户重新登录


如果云控制台中的所有者电子邮件错误,并且您仍然可以使用该帐户登录,只需在IAM菜单中使用正确的帐户作为所有者,然后您可以在必要时删除拼写错误的帐户。

首先从您的终端设置基本身份验证:

gcloud auth application-default login
然后按如下方式设置项目:

gcloud config set project <put your project id>      
此处
sa description
是服务帐户的可选描述。
sa display name
是服务帐户的友好名称。
项目id
是您的谷歌云项目的id

然后添加所有者策略:

gcloud projects add-iam-policy-binding my-project-123 \
--member serviceAccount:sa-name@project-id.iam.gserviceaccount.com \
--role roles/owner
然后创建服务帐户密钥:

gcloud iam service-accounts keys create ~/key.json \
 --iam-account sa-name@project-id.iam.gserviceaccount.com
然后使用此键:

export GCLOUD_APPLICATION_CREDENTIALS="~/key.json"
gcloud auth activate-service-account --key-file \
$GCLOUD_APPLICATION_CREDENTIALS
然后启用:

gcloud services enable cloudresourcemanager.googleapis.com —project=$GOOGLE_CLOUD_PROJECT

谢谢这帮我摆脱困境谢谢Andres两个答案都帮我摆脱困境
gcloud services enable cloudresourcemanager.googleapis.com —project=$GOOGLE_CLOUD_PROJECT