'ignore_changes doesn't work for Cloud Resource Manager API (GCP)
This Terraform code below including "ignore_changes" is to enable "Cloud Resource Manager API" On GCP:
resource "google_project_service" "crm_api" {
service = "cloudresourcemanager.googleapis.com"
lifecycle {
ignore_changes = [
service
]
}
}
Then, I ran the command below to apply:
terraform apply -auto-approve
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Then, "Cloud Resource Manager API" is enabled:

Then, I manually disabled "Cloud Resource Manager API":

Then again, I ran the command below to apply:
terraform apply -auto-approve
But I got this error below which means ignore_changes doesn't work for "Cloud Resource Manager API":
Error: Error when reading or editing Project Service myproject-339623/cloudresourcemanager.googleapis.com: googleapi: Error 403: Cloud Resource Manager API has not been used in project 699106206783 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=699106206783 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
So, one by one, I ran this command below:
terraform refresh
And this command below:
terraform apply -refresh-only
But I still got the same error below for both commands above:
Error: Error when reading or editing Project Service myproject-339623/cloudresourcemanager.googleapis.com: googleapi: Error 403: Cloud Resource Manager API has not been used in project 699106206783 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=699106206783 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
Finally, I checked the state with this command below:
terraform show
The state is as shown below:
♯ google_project_service.crm_api: resource "google_project_service" "crm_api" { disable_on_destroy = true id = "our-mediator-339620/cloudresourcemanager.googleapis.com" project = "our-mediator-339620" service = "cloudresourcemanager.googleapis.com" }
Why doesn't "ignore_changes" work for "Cloud Resource Manager API"?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
