terraform-ftw
terraform-ftw

Reputation: 131

GCP - Terraform - google_project_services module breaks terraform pipeline

As per subject title, when using this module to just delete the default network and nothing else, this module breaks my terraform entirely, even when the module is removed/commented out, I get the same error still:

resource "google_project_service" "service" {
  project = var.project_id
  service = "compute.googleapis.com"
  disable_dependent_services = false
  disable_on_destroy = false

  provisioner "local-exec" {
    command = "gcloud -q compute networks delete default --project=${var.project_id}"
  }
}

This is the error I get (replaced my actual project id with "project_id"):

Error: Error when reading or editing Project Service project_id/compute.googleapis.com: Error disabling service "compute.googleapis.com" for project "project_id": googleapi: Error 400: The service compute.googleapis.com is depended on by the following active service(s): container.googleapis.com; Please specify disable_dependent_services=true if you want to proceed with disabling all services.
│ Help Token: Ae-hA1POavq8x9V18i7Um0cW3sx_9lXuuNzjqDzX3zZ3HEYjJ91bGelEobL22DVMdY27NCRrCtZbyE-GbagPtdmxWhdpSamwl0JJomQ4KTRUQDK5
│ Details:
│ [
│   {
│     "@type": "type.googleapis.com/google.rpc.PreconditionFailure",
│     "violations": [
│       {
│         "subject": "?error_code=100001\u0026service_name=compute.googleapis.com\u0026services=container.googleapis.com",
│         "type": "googleapis.com"
│       }
│     ]
│   },
│   {
│     "@type": "type.googleapis.com/google.rpc.ErrorInfo",
│     "domain": "serviceusage.googleapis.com",
│     "metadata": {
│       "service_name": "compute.googleapis.com",
│       "services": "container.googleapis.com"
│     },
│     "reason": "COMMON_SU_SERVICE_HAS_DEPENDENT_SERVICES"
│   }

│ ] │ , failedPrecondition

Have had issues like this before with this module when wanting to enable gcp apis in a newly created project with terraform so just stopped using it.

Any ideas how I fix the above?

I am doing a terraform init, refresh, plan and apply, this fails and gets the error above on the terraform apply stage.

Upvotes: 1

Views: 2077

Answers (2)

terraform-ftw
terraform-ftw

Reputation: 131

seems the module/resource was still defined in the state file, removing that fixed it

Upvotes: 1

sudhar chrome
sudhar chrome

Reputation: 75

Since some other service using compute.googleapis.com as a dependent service. so its stopping compute.googleapis.com from disabling because it might affect those dependent service. Here is the Reference Doc1 Try like this it should work

 disable_dependent_services = True

Upvotes: 0

Related Questions