Apply and destroy

:wave: Hello, team! Been working with TF a few months, had a few questions/discussion to get into based on a SO post.
Been getting a lot of errors 403 and 409, using terraform on gcp (even on a fresh project), where I have to manually enable an API upon apply and manually delete a resource upon destroy, not always related to a service that maybe dependant or instantiated on a child resource, like SQL and then a db. I read that there is a Terraform resource definition called “google_project_service” that allows one to automatically enable a service (API). This is documented at google_project_service. Would I need to create one per service in
resource “google_project_service” “project”, because only one service argument can be taken.

resource "google_project_service" "project" {
  project = "your-project-id"
  service = "iam.googleapis.com"
  timeouts {
    create = "30m"
    update = "40m"
  }

  disable_dependent_services = true
  disable_on_destroy = true
}

Below is what I used now but I have to manually enable some apis and destroy some and not just ones with dependants.

resource "google_project_service" "iam" {
  service            = "iam.googleapis.com"
  # disable_on_destroy = true
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.