(Terraform) 错误 403: Cloud 运行 Admin API 之前未在项目 905986752003 中使用过或被禁用。通过访问 https://console.d 启用它
(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
在 GCP 上,我将下面的 Terraform 代码应用到 运行 Cloud 运行 服务“渲染器”:
resource "google_cloud_run_service" "renderer" {
name = "renderer"
location = "asia-northeast1"
template {
spec {
containers {
image = "gcr.io/${var.project_id}/renderer:latest"
}
}
}
}
但是我得到了这个错误:
Error creating Service: googleapi: Error 403: Cloud Run Admin API has
not been used in project 905986752003 before or it is disabled. Enable
it by visiting
https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003
then retry. If you enabled this API recently, wait a few minutes for
the action to propagate to our systems and retry.
所以,我去了上面这个错误中显示的url https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003:
然后,启用云运行API:
然后,再次应用此 Terraform 代码:
resource "google_cloud_run_service" "renderer" {
name = "renderer"
location = "asia-northeast1"
template {
spec {
containers {
image = "gcr.io/${var.project_id}/renderer:latest"
}
}
}
}
最后,我可以 运行 云 运行 服务“renderer”:
现在,我想使用 Terraform 代码启用 Cloud 运行 API:
是否可以使用 Terraform 代码启用 Cloud 运行 API,如果可能,如何实现我要使用 Terraform 代码启用 Cloud 运行 API 吗?
是的,可以使用 Terraform 代码启用 Cloud 运行 API。因此,您需要添加此 Terraform 代码:
resource "google_project_service" "cloud_run_api" {
service = "run.googleapis.com"
}
然后,你还需要添加"depends_on"块和"google_project_service.cloud_run_api"等待要启用 Cloud 运行 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
]
}
否则,你会得到同样的错误:
Error creating Service: googleapi: Error 403: Cloud Run Admin API has
not been used in project 905986752003 before or it is disabled. Enable
it by visiting
https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003
then retry. If you enabled this API recently, wait a few minutes for
the action to propagate to our systems and retry.
这是完整的 Terrafrom 代码:
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
]
}
此外,启用Cloud 运行后,您可以在重定向到的页面中找到服务名称“run.googleapis.com” API:
resource "google_project_service" "cloud_run_api" {
service = "run.googleapis.com" // Service name
}
因此,在您启用 Cloud 运行 API 之后:
您被重定向到此页面:
然后,您可以在详细信息部分找到服务名称“run.googleapis.com”:
在 GCP 上,我将下面的 Terraform 代码应用到 运行 Cloud 运行 服务“渲染器”:
resource "google_cloud_run_service" "renderer" {
name = "renderer"
location = "asia-northeast1"
template {
spec {
containers {
image = "gcr.io/${var.project_id}/renderer:latest"
}
}
}
}
但是我得到了这个错误:
Error creating Service: googleapi: Error 403: Cloud Run Admin API has not been used in project 905986752003 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
所以,我去了上面这个错误中显示的url https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003:
然后,启用云运行API:
然后,再次应用此 Terraform 代码:
resource "google_cloud_run_service" "renderer" {
name = "renderer"
location = "asia-northeast1"
template {
spec {
containers {
image = "gcr.io/${var.project_id}/renderer:latest"
}
}
}
}
最后,我可以 运行 云 运行 服务“renderer”:
现在,我想使用 Terraform 代码启用 Cloud 运行 API:
是否可以使用 Terraform 代码启用 Cloud 运行 API,如果可能,如何实现我要使用 Terraform 代码启用 Cloud 运行 API 吗?
是的,可以使用 Terraform 代码启用 Cloud 运行 API。因此,您需要添加此 Terraform 代码:
resource "google_project_service" "cloud_run_api" {
service = "run.googleapis.com"
}
然后,你还需要添加"depends_on"块和"google_project_service.cloud_run_api"等待要启用 Cloud 运行 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
]
}
否则,你会得到同样的错误:
Error creating Service: googleapi: Error 403: Cloud Run Admin API has not been used in project 905986752003 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
这是完整的 Terrafrom 代码:
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
]
}
此外,启用Cloud 运行后,您可以在重定向到的页面中找到服务名称“run.googleapis.com” API:
resource "google_project_service" "cloud_run_api" {
service = "run.googleapis.com" // Service name
}
因此,在您启用 Cloud 运行 API 之后:
您被重定向到此页面:
然后,您可以在详细信息部分找到服务名称“run.googleapis.com”: