【问题标题】:(Terraform) Error 403: Cloud Run Admin API has not been used in project 905986752003 before or it is disabled. Enable it by visiting https://console.d(Terraform) 错误 403: Cloud Run Admin API 之前未在项目 905986752003 中使用或被禁用。通过访问 https://console.d 启用它
【发布时间】:2023-02-09 06:33:11
【问题描述】:

全球控制点,我应用了这个地貌下面的代码运行Cloud Run 服务“渲染器”:

resource "google_cloud_run_service" "renderer" {
  name     = "renderer"
  location = "asia-northeast1"

  template {
    spec {
      containers {
        image = "gcr.io/${var.project_id}/renderer:latest"
      }
    }
  }
}

但是我得到了这个错误:

创建服务时出错:googleapi:错误 403:Cloud Run Admin API 有 之前未在项目 905986752003 中使用或已禁用。使能够 它通过访问 https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003 然后重试。如果您最近启用了此 API,请等待几分钟 传播到我们的系统并重试的操作。

因此,我访问了上面错误中显示的 url https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003

然后,启用云运行接口:

然后,应用这个地貌再次编码:

resource "google_cloud_run_service" "renderer" {
  name     = "renderer"
  location = "asia-northeast1"

  template {
    spec {
      containers {
        image = "gcr.io/${var.project_id}/renderer:latest"
      }
    }
  }
}

终于,我可以跑了Cloud Run 服务“渲染器”:

现在,我想启用云运行接口地貌代码:

是否可以启用云运行接口地貌代码,如果可能的话,我该如何启用云运行接口地貌代码?

Buy me a coffee!!

【问题讨论】:

    标签: google-cloud-platform terraform devops google-cloud-run terraform-provider-gcp


    【解决方案1】:

    是的,可以启用云运行接口地貌代码。所以,你需要添加这个地貌代码:

    resource "google_project_service" "cloud_run_api" {
      service = "run.googleapis.com"
    }
    

    然后,您还需要添加“依赖于取决于”块与“google_project_service.cloud_run_api”等待云运行接口启用:

    resource "google_cloud_run_service" "renderer" {
      name     = "renderer"
      location = "asia-northeast1"
    
      template {
        spec {
          containers {
            image = "gcr.io/${var.project_id}/renderer:latest"
          }
        }
      }
      depends_on = [ // Here
        google_project_service.cloud_run_api
      ]
    }
    

    否则,你会得到同样的错误:

    创建服务时出错:googleapi:错误 403:Cloud Run Admin API 有 之前未在项目 905986752003 中使用或已禁用。使能够 它通过访问 https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003 然后重试。如果您最近启用了此 API,请等待几分钟 传播到我们的系统并重试的操作。

    这是完整的地貌代码:

    resource "google_project_service" "cloud_run_api" {
      service = "run.googleapis.com"
    }
    
    resource "google_cloud_run_service" "renderer" {
      name     = "renderer"
      location = "asia-northeast1"
    
      template {
        spec {
          containers {
            image = "gcr.io/${var.project_id}/renderer:latest"
          }
        }
      }
      depends_on = [
        google_project_service.cloud_run_api
      ]
    }
    

    此外,您还可以找到服务名称“run.googleapis.com”在您启用后重定向到的页面中云运行接口:

    resource "google_project_service" "cloud_run_api" {
      service = "run.googleapis.com" // Service name
    }
    

    所以,启用后云运行接口:

    您被重定向到此页面:

    然后,你可以找到服务名称“run.googleapis.com”细节部分:

    Buy me a coffee!!

    【讨论】:

      猜你喜欢
      • 2017-05-13
      • 2019-02-06
      • 1970-01-01
      • 2023-03-13
      • 2014-08-26
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多