Google provider upgrade to new version

I received the following email from GCP.

After July 6, 2020, all new and existing Instance Template Google Compute Engine resources will have an auto-generated name attribute for all network interfaces. These resources will stop being compatible with Terraform Google Cloud Platform Provider versions below 2.20.3 or 3.12.0.

To continue using Terraform with Google Cloud Platform, you must upgrade your Provider to version 2.20.3, 3.12.0, or greater. These versions ensure the provider continues to manage Instance Template resources. After July 6, 2020, runs of terraform plan and terraform apply using a provider version older than these will start failing. As a result, if you configure Instance Templates with Terraform using a Provider version below 2.20.3 or 3.12.0, you will receive the following error message:

  • Error setting network_interface: Invalid address to set: []string{"network_interface", "0", "name"})

What do I need to do?

To ensure you can continue to manage Instance Template resources, please upgrade your provider version by July 6, 2020.

We currently use Google Provider version " 3.9.0 " and that’s why I received an email from GCP to update the GCP Provider version.

I upgraded the version to " 3.20.0 " and performed the following steps.

Command: terraform init

This gave a log as following which shows that TF has downloaded the upgraded GCP provider version.

Initializing provider plugins…

  • Checking for available provider plugins…
  • Downloading plugin for provider “google” (hashicorp/google) 3.20.0…

Command: terraform plan and terraform apply

  • to already existing Compute Instance template and Managed Instance group in our GCP project that creates a Compute engine. And I did not see any failures or errors as GCP Email mentioned above.

  • I executed the above commands to create new resources Compute Instance template and Managed Instance group in our GCP project and again I could see the resources have been created with no errors .

But according to the GCP email, for versions after 3.12.0, they would be creating auto-generated name attribute for all network interfaces but we did not see any such error occurring in our case. The following is the sample code we use.

resource "google_compute_network" "project_vpc" {
name                    = "data-project"
description             = "Encapsulates resources for this project"
routing_mode            = "REGIONAL"
project                 = "project_id"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "dw_subnet" {
depends_on                = [
google_compute_network.project_vpc,
google_service_networking_connection.network_connection_name
]

network                   = google_compute_network.project_vpc.self_link
name                      = "subnet-name-goes-here"
ip_cidr_range             = "cid-rgoes-here"
region                    = "region-goes-here"
private_ip_google_access  = true
}

resource "google_compute_address" "custom_address" {
name         = "custom_address-name"
address_type = "EXTERNAL"
region       = var.dw_subnet
}

resource "google_compute_instance_template" "bastion_template" {
name = "instance-template-name-123"
description = "Template description"

network_interface {
network    = google_compute_network.project_vpc.self_link
subnetwork = google_compute_subnetwork.dw_composer_subnet.self_link

access_config {
nat_ip = google_compute_address.custom_address.address
}
}

.
.
other configuration details
.
.
}

With the above code, I do not see any issue in creating resources and no error occurred while running terraform init, plan, apply with Google provider version as **3.20.0**. So just wondering if this is expected or if something else is there that I’m missing.

1 Like

Thank you Profile - nandakarvapaly - HashiCorp Discuss
I was facing the same issue and it is resolved.