From 0a17e69872b26843bdcdf1768740b240c4d62f53 Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Thu, 28 Oct 2021 18:41:44 -0500 Subject: [PATCH] Remove instance_group_urls (#5378) --- .../instance_group_named_port_gke.tf.erb | 4 +- .../resource_container_cluster.go.erb | 40 ------------------- .../resource_container_cluster_test.go.erb | 2 +- .../docs/d/container_cluster.html.markdown | 2 +- .../docs/r/container_cluster.html.markdown | 3 -- 5 files changed, 4 insertions(+), 47 deletions(-) diff --git a/mmv1/templates/terraform/examples/instance_group_named_port_gke.tf.erb b/mmv1/templates/terraform/examples/instance_group_named_port_gke.tf.erb index 5e2279017ebd..3a4b492eca8a 100644 --- a/mmv1/templates/terraform/examples/instance_group_named_port_gke.tf.erb +++ b/mmv1/templates/terraform/examples/instance_group_named_port_gke.tf.erb @@ -1,5 +1,5 @@ resource "google_compute_instance_group_named_port" "<%= ctx[:primary_resource_id] %>" { - group = google_container_cluster.my_cluster.instance_group_urls[0] + group = google_container_cluster.my_cluster.node_pool[0].instance_group_urls[0] zone = "us-central1-a" name = "http" @@ -7,7 +7,7 @@ resource "google_compute_instance_group_named_port" "<%= ctx[:primary_resource_i } resource "google_compute_instance_group_named_port" "<%= ctx[:primary_resource_id] %>s" { - group = google_container_cluster.my_cluster.instance_group_urls[0] + group = google_container_cluster.my_cluster.node_pool[0].instance_group_urls[0] zone = "us-central1-a" name = "https" diff --git a/mmv1/third_party/terraform/resources/resource_container_cluster.go.erb b/mmv1/third_party/terraform/resources/resource_container_cluster.go.erb index 1e785046d323..24727196d77d 100644 --- a/mmv1/third_party/terraform/resources/resource_container_cluster.go.erb +++ b/mmv1/third_party/terraform/resources/resource_container_cluster.go.erb @@ -938,14 +938,6 @@ func resourceContainerCluster() *schema.Resource { Description: `The IP address of this cluster's Kubernetes master.`, }, - "instance_group_urls": { - Type: schema.TypeList, - Computed: true, - Deprecated: `Please use node_pool.instance_group_urls instead.`, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: `List of instance group URLs which have been assigned to the cluster.`, - }, - "master_version": { Type: schema.TypeString, Computed: true, @@ -1882,14 +1874,6 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro return err } - igUrls, err := getInstanceGroupUrlsFromManagerUrls(config, userAgent, cluster.InstanceGroupUrls) - if err != nil { - return err - } - if err := d.Set("instance_group_urls", igUrls); err != nil { - return err - } - if err := d.Set("vertical_pod_autoscaling", flattenVerticalPodAutoscaling(cluster.VerticalPodAutoscaling)); err != nil { return err } @@ -2964,30 +2948,6 @@ func containerClusterAwaitRestingState(config *Config, project, location, cluste return state, err } -// container engine's API returns the instance group manager's URL instead of the instance -// group's URL in its responses, while the field is named as if it should have been the group -// and not the manager. This shim should be supported for backwards compatibility reasons. -func getInstanceGroupUrlsFromManagerUrls(config *Config, userAgent string, igmUrls []string) ([]string, error) { - instanceGroupURLs := make([]string, 0, len(igmUrls)) - for _, u := range igmUrls { - if !instanceGroupManagerURL.MatchString(u) { - instanceGroupURLs = append(instanceGroupURLs, u) - continue - } - matches := instanceGroupManagerURL.FindStringSubmatch(u) - instanceGroupManager, err := config.NewComputeClient(userAgent).InstanceGroupManagers.Get(matches[1], matches[2], matches[3]).Do() - if isGoogleApiErrorWithCode(err, 404) { - // The IGM URL is stale; don't include it - continue - } - if err != nil { - return nil, fmt.Errorf("Error reading instance group manager returned as an instance group URL: %s", err) - } - instanceGroupURLs = append(instanceGroupURLs, instanceGroupManager.InstanceGroup) - } - return instanceGroupURLs, nil -} - func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig { l := configured.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb index 4e96d3708868..38d343f26847 100644 --- a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -3426,7 +3426,7 @@ resource "google_compute_backend_service" "my-backend-service" { protocol = "HTTP" backend { - group = element(google_container_cluster.primary.instance_group_urls, 1) + group = element(google_container_cluster.primary.node_pool[0].instance_group_urls, 1) } health_checks = [google_compute_http_health_check.default.self_link] diff --git a/mmv1/third_party/terraform/website/docs/d/container_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/d/container_cluster.html.markdown index 94ede243bef1..9638ceb59388 100644 --- a/mmv1/third_party/terraform/website/docs/d/container_cluster.html.markdown +++ b/mmv1/third_party/terraform/website/docs/d/container_cluster.html.markdown @@ -24,7 +24,7 @@ output "endpoint" { } output "instance_group_urls" { - value = data.google_container_cluster.my_cluster.instance_group_urls + value = data.google_container_cluster.my_cluster.node_pool[0].instance_group_urls } output "node_config" { diff --git a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown index 777599bd54c9..35811e907610 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown @@ -925,9 +925,6 @@ exported: * `endpoint` - The IP address of this cluster's Kubernetes master. -* `instance_group_urls` - List of instance group URLs which have been assigned - to the cluster. - * `label_fingerprint` - The fingerprint of the set of labels for this cluster. * `maintenance_policy.0.daily_maintenance_window.0.duration` - Duration of the time window, automatically chosen to be