如何授予帐户列出已启用的API的权限?

问题描述:

在Cloud Build上进行构建时,收到以下警告:

During a build on Cloud Build, I get the following warning:

步骤2:警告:无法验证是否为项目[xxxxx]启用了Appengine Flexible API.您可能没有权限列出此项目上已启用的服务.如果未启用它,则可能会在运行部署中引起问题.请要求项目所有者确保已启用Appengine Flexible API,并且该帐户有权列出已启用的API.

我想摆脱此警告,以获取干净的构建日志.

I'd like to get rid of this warning to get a clean build log.

由于构建成功,因此问题一定与禁用Appengine Flexible API无关.

Since the build succeeds, the problem must not be with Appengine Flexible API being disabled.

否;问题必须是该帐户无权列出已启用的API.如何解决该问题(在控制台中还是在命令行中)?

No; the problem must be that the account does not have permission to list enabled APIs. How can I fix that (either in the Console or at the command line)?

要列出可用的服务,您需要权限 services.list .您可以通过授予角色来授予此权限,其中包括所述权限,例如 roles/serviceusage.serviceUsageViewer ,或者您可以创建

To list the services available, you need the permission services.list. You can grant this permission via granting a role that includes said permission, like roles/serviceusage.serviceUsageViewer, or you can create your own personalised role with that permission only, if you wish to.

有关如何启用API的信息:首先使用 $ gcloud服务列表 .默认情况下,它显示该帐户的所有已启用服务.

On how to enable the API: First check if said account has or hasn't said API enabled, which looks unlikely, with $ gcloud services list. By default, it shows all the enabled services for said account.

如果在上述列表中看不到"appengineflex.googleapis.com",则可以运行 $ gcloud服务使appengineflex.googleapis.com 能够做到这一点.

If you can't see 'appengineflex.googleapis.com' in said list, you can run $ gcloud services enable appengineflex.googleapis.com to do so.