Google Cloud IAM 中缺少 Cloud Function 用户代理角色

Missing Cloud Function User Agent role in Google Cloud IAM

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

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 角色给了我另一个惊喜 - 列表中缺少该角色,它应该在服务管理下:

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

gcloud services enable cloudfunctions.googleapis.com

但还是没有成功。

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

TIA - 乔

请尝试以下步骤解决此问题:

禁用云功能API:

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

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

使用 CLI 或使用 IAM 下的 GCP 控制台删除云功能成员帐户。

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

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

启用云功能API:

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

返回 GCP 控制台。您应该找到一个新的 Google Cloud Functions Service Agent 成员。

注:

您使用了错误的命令来添加 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"