'(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

On GCP, I applied this Terraform code below to run the Cloud Run service "renderer":

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

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

But I got this error:

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.

So, I went to the url https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=905986752003 shown in this error above:

enter image description here

Then, enabled Cloud Run API:

enter image description here

Then, applied this Terraform code again:

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

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

Finally, I could run the Cloud Run service "renderer":

enter image description here

Now, I want to enable Cloud Run API with Terraform code:

enter image description here

Is it possible to enable Cloud Run API with Terraform code and if it's possible, how do I enable Cloud Run API with Terraform code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source