启用 GCP cloudresourcemanager gcloud config joe.bloggs@googlemail.com 帐户与 GCP 项目所有者角色 joe.bloggs@gmail.com 不匹配
Enabling GCP cloudresourcemanager gcloud config joe.bloggs@googlemail.com account does not match GCP project owner role joe.bloggs@gmail.com
正在尝试 运行:
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 配置中将其更改为 gmail.com,在项目所有者角色中将其更改为 googlemail.com,但似乎无法做到。
我了解到用于登录 gcloud 的 gmail 帐户存在错误,请尝试使用 "gcloud auth list" command to verify the account used in gcloud, you can then use the "gcloud auth revoke --all" command to logout from all acocunts in gcloud and after that try "gcloud auth login email@address.com" 使用正确的帐户重新登录。
如果云控制台中的所有者电子邮件错误,但您仍然可以使用该帐户登录,只需 add another IAM role 在 IAM 菜单中使用正确的帐户作为所有者,然后您可以删除拼写错误的帐户如有必要
首先从您的终端设置基本身份验证:
gcloud auth application-default login
然后像下面这样设置项目:
gcloud config set project <put your project id>
然后使用所有者设置创建服务帐户
gcloud iam service-accounts create sa-name \
--description="sa-description" \
--display-name="sa-display-name"
这里 sa-description
是服务帐户的可选描述。
sa-display-name
是服务帐户的友好名称。
project-id
是您的 Google Cloud 项目的 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
正在尝试 运行:
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 配置中将其更改为 gmail.com,在项目所有者角色中将其更改为 googlemail.com,但似乎无法做到。
我了解到用于登录 gcloud 的 gmail 帐户存在错误,请尝试使用 "gcloud auth list" command to verify the account used in gcloud, you can then use the "gcloud auth revoke --all" command to logout from all acocunts in gcloud and after that try "gcloud auth login email@address.com" 使用正确的帐户重新登录。
如果云控制台中的所有者电子邮件错误,但您仍然可以使用该帐户登录,只需 add another IAM role 在 IAM 菜单中使用正确的帐户作为所有者,然后您可以删除拼写错误的帐户如有必要
首先从您的终端设置基本身份验证:
gcloud auth application-default login
然后像下面这样设置项目:
gcloud config set project <put your project id>
然后使用所有者设置创建服务帐户
gcloud iam service-accounts create sa-name \
--description="sa-description" \
--display-name="sa-display-name"
这里 sa-description
是服务帐户的可选描述。
sa-display-name
是服务帐户的友好名称。
project-id
是您的 Google Cloud 项目的 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