Issues with transitioning from google_project_services => google_project_service

We have encountered an issue and am trying this route before creating a “Question” in GitHub Terraform Providers Issues.

We’re slowly updating our Terraform version and Terraform provider versions.
Our versions are as follows:

  • Terraform v0.11.14
  • provider.google v2.20.3 – this is the highest version we can go before having to upgrade Terraform to v0.12.x and we want a clean Terraform plan before upgrading.

As google_project_services is deprecated, we’re moving to the google_project_service resource. I’ve imported the enabled Service APIs (via the Terraform import command) and have the config as shown below, but Terraform keeps wanting to make a change. How do I fix this so no changes are required?

~ google_project_service.prod-bigquery
     disable_on_destroy: "" => "true"

In addition, will deleting the old google_project_services block cause our APIs to be disabled since they are defined via the google_project_service block, as shown below.

- google_project_services.production

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place
  - destroy

Terraform will perform the following actions:

  ~ google_project_service.prod-bigquery
      disable_on_destroy: "" => "true"

  - google_project_services.production


Plan: 0 to add, 1 to change, 1 to destroy.

That issue with import is a bug, and we should fix it. Unfortunately we wouldn’t backport the fix to the 2.X series so it wouldn’t actually help you out, but if you wanted to file a bug report in the provider repo, we’d certainly appreciate it. In the meantime, that change for disable_on_destroy is a no-op, so it’s perfectly safe to apply (see https://github.com/terraform-providers/terraform-provider-google/blob/v2.20.3/google/resource_google_project_service.go#L182-L186)

Deleting the old block will only cause your APIs to be disabled if disable_on_destroy is set to true. If you run terraform show, it’ll tell you what it’s currently set to, or you could explicitly set it to false in your config. When you do that, make sure to run terraform apply before you run terraform destroy so that the change is captured in state.

Hope that helps!

1 Like

Great! That’s exactly the information I was looking for!

I’ll also file a bug report for that import bug.