【问题标题】:Missing Cloud Function User Agent role in Google Cloud IAMGoogle Cloud IAM 中缺少 Cloud Function 用户代理角色
【发布时间】:2019-05-25 20:55:06
【问题描述】:

我正在一个 Google Cloud 项目中处理一系列 Cloud Functions,但由于某种原因,我突然收到此错误:

Deployment failure:
Missing necessary permission resourcemanager.projects.getIamPolicy for service-1092904037961@gcf-admin-robot.iam.gserviceaccount.com on resource projects/la-cloud-functions. Please grant service-1092904037961@gcf-admin-robot.iam.gserviceaccount.com the Cloud Functions Service Agent role. You can do that by running 'gcloud iam service-accounts add-iam-policy-binding projects/la-cloud-functions --member=service-1092904037961@gcf-admin-robot.iam.gserviceaccount.com --role=Cloud Functions Service Agent'

当我尝试运行修改后的命令时,除了格式错误的错误响应(你不能有--role=Cloud Functions Service Agent - 它应该是--role=roles/cloudfunctions.serviceAgent):

gcloud iam service-accounts add-iam-policy-binding projects/la-cloud-functions --member=service-1092904037961@gcf-admin-robot.iam.gserviceaccount.com --role=roles/cloudfunctions.serviceAgent

我收到此错误:

The requested URL <code>/v1/projects/la-cloud-functions/serviceAccounts/projects/la-cloud-functions:getIamPolicy?alt=json</code> was not found on this server.

最后,尝试通过控制台分配 Cloud Functions Server Agent 角色给了我另一个惊喜 - 列表中缺少该角色,它应该在服务管理下:

我已尝试通过使用以下命令重新启用 Cloud Functions API 来重置服务帐户:

gcloud services enable cloudfunctions.googleapis.com

但同样,没有成功。

有人对如何解决此问题并使 Cloud Functions 服务代理角色再次可用有任何想法吗?

TIA - 乔

【问题讨论】:

  • 如果其他人遇到这个问题,我运行了 John Hanley 在他的回答中提供的服务帐户创建脚本,但它没有出现。 Google 在 IAM 页面右上角添加了一个“包括 Google 提供的角色授予”复选框,点击它就会出现。

标签: google-cloud-platform google-cloud-functions google-iam


【解决方案1】:

尝试以下步骤来解决这个问题:

禁用 Cloud Functions API:

gcloud services disable cloudfunctions.googleapis.com --project la-cloud-functions

等待大约一分钟,让禁用完成。

使用 CLI 或使用 IAM 下的 GCP Console 删除云函数成员帐户。

gcloud projects remove-iam-policy-binding la-cloud-functions --member="serviceAccount:service-1092904037961@gcf-admin-robot.iam.gserviceaccount.com" --role="roles/cloudfunctions.serviceAgent"

等一下。然后验证该成员是否已在 GCP Console 中的 IAM 下删除。

启用云函数 API:

gcloud services enable cloudfunctions.googleapis.com --project la-cloud-functions

返回 GCP 控制台。您应该会找到一个新的 Google Cloud Functions 服务代理成员。

注意:

您使用了错误的命令来添加cloudfunctions.serviceAgent。这是正确的命令:

gcloud projects add-iam-policy-binding la-cloud-functions --member="serviceAccount:service-1092904037961@gcf-admin-robot.iam.gserviceaccount.com" --role="roles/cloudfunctions.serviceAgent"

【讨论】:

  • 非常感谢约翰的完整回答。当我尝试通过 shell 禁用 Cloud Functions 成员帐户时,它说我需要先删除所有功能。如果没有必要,我没有采取那个相当激烈的步骤,而是使用您修改后的命令添加 cloudfunctions.serviceAgent - 效果很好,我能够运行 Cloud Build 来部署我的功能。我希望这能解决任何其他问题,如果没有,我将完成禁用/启用过程。
  • @JoeLowery - 很高兴为您提供帮助。如果您不是每天都使用它,这些 IAM 东西可能会变得复杂/令人困惑。
  • 遇到了同样的问题,@JohnHanley 你的最后一个命令对我来说已经足够了。谢谢!
猜你喜欢
  • 1970-01-01
  • 2019-12-09
  • 2020-05-27
  • 2021-06-17
  • 2017-09-21
  • 2019-06-08
  • 1970-01-01
  • 2021-07-08
  • 2020-02-15
相关资源
最近更新 更多