hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.28k stars 1.72k forks source link

Issue with renaming bigquery-json.googleapis.com on 2.20.0 -> 3.9.0 upgrade #5715

Closed aleks-m closed 4 years ago

aleks-m commented 4 years ago

Hi.

I am trying to upgrade Google provider in my configs from 2.20.0 to 3.9.0. I know what bigquery-json.googleapis.com has been renamed to bigquery.googleapis.com in 3.x. I made a corresponding change in configs and got this on terraform apply:

Config snippet:

variable "project" {
}

locals {
  services = [
    "bigquery.googleapis.com",
    "bigtable.googleapis.com",
    "bigtableadmin.googleapis.com",
    "bigtabletableadmin.googleapis.com",
    "cloudapis.googleapis.com",
    "cloudbilling.googleapis.com",
    "clouddebugger.googleapis.com",
    "cloudresourcemanager.googleapis.com",
    "cloudtrace.googleapis.com",
    "compute.googleapis.com",
    "container.googleapis.com",
    "containerregistry.googleapis.com",
    "dataflow.googleapis.com",
    "datastore.googleapis.com",
    "deploymentmanager.googleapis.com",
    "iam.googleapis.com",
    "logging.googleapis.com",
    "monitoring.googleapis.com",
    "pubsub.googleapis.com",
    "replicapool.googleapis.com",
    "replicapoolupdater.googleapis.com",
    "resourceviews.googleapis.com",
    "servicemanagement.googleapis.com",
    "sql-component.googleapis.com",
    "sqladmin.googleapis.com", // sqladmin is enabled
    "storage-api.googleapis.com",
    "storage-component.googleapis.com",
    "language.googleapis.com",
  ]
}

resource "google_project_service" "service" {
  project = var.project
  count   = length(local.services)
  service = element(local.services, count.index)
}
  # module.enable_app_api.google_project_service.service[0] must be replaced
-/+ resource "google_project_service" "service" {
        disable_on_destroy = true
      ~ id                 = "foobar/bigquery-json.googleapis.com" -> (known after apply)
        project            = "foobar"
      ~ service            = "bigquery-json.googleapis.com" -> "bigquery.googleapis.com" # forces replacement

      - timeouts {}
    }
Error: Error reading Project Service foobar/bigquery-json.googleapis.com: Error disabling service "bigquery-json.googleapis.com" for project "foobar": googleapi: Error 400: The service bigquery.googleapis.com is depended on by the following active services: bigquerystorage.googleapis.com,cloudapis.googleapis.com,composer.googleapis.com,container.googleapis.com,dataflow.googleapis.com,datafusion.googleapis.com,resourceviews.googleapis.com; Please specify disable_dependent_services=true if you want to proceed with disabling all services., failedPrecondition

From https://www.terraform.io/docs/providers/google/guides/version_3_upgrade.html#resource-google_container_cluster:

The provider will automatically convert between them as the upstream API migration continues.

Why is it trying to recreate a service in such destructive way instead? I can't add disable_dependent_services=true and disable all those services on a production environment. Is there any other way to solve this issue? What can you recommend?

Thanks.

rileykarson commented 4 years ago

You can set disable_on_destroy to false during the transition, as shown in the example. You may need to commit the value first by running terraform apply while the old bigquery service name is still set (Terraform doesn't read the new value from config during destroys).

Sorry! That part of the upgrade ended up a little less smooth than we expected.

For what it's worth, you probably don't need to manage that service at all anymore. It's enabled by default on all projects, and it's depended on by a couple of high-priority services, particularly container.googleapis.com.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!