首页 > 解决方案 > 如何使用 gcloud 在 GCP 中启用 API 服务进行故障排除

问题描述

执行 terraform apply 时,我被要求为我的项目启用 IAM API 时收到此错误。

Error: Error creating service account: googleapi: Error 403: Identity and Access 
Management (IAM) API has not been used in project [PROJECT-NUMBER] before or it is 
disabled. Enable it by visiting 
https://console.developers.google.com/apis/api/iam.googleapis.com/overview?
project=[PROJECT-NUMBER] then retry. If you enabled this API recently, wait a few 
minutes for the action to propagate to our systems and retry., 
accessNotConfigured

当我尝试使用 gcloud 启用它时,服务启用只是挂起。有什么方法可以获取更多信息吗?

根据Google Dashboard,一切都是绿色的。

我在使用 UI 时也看到了同样的问题。

$ gcloud services enable iam.googleapis.com container.googleapis.com

错误信息

ERROR: gcloud crashed (WaitException): last_result=True, last_retrial=178, time_passed_ms=1790337,time_to_wait=10000

标签: apigoogle-cloud-platformgcloud

解决方案


添加--log-http到(任何)gcloud命令以获取底层 API 调用的详细日志记录。这些可能会提供有关错误发生位置的更多详细信息。

您也可能希望明确引用该项目:--project=....

是否需要启用 IAM?这是一项如此基础的服务,如果不启用它,我很惊讶任何东西都会起作用。


推荐阅读