From 9c2ba3cd2683b36997f0155ca9491ca7f02974dc Mon Sep 17 00:00:00 2001 From: Paddy Carver Date: Mon, 3 Jun 2019 15:32:53 -0700 Subject: [PATCH] Add top-level services_ipv4_cidr attr to container_cluster. There's a computed, output-only services_ipv4_cidr attribute for GKE Clusters that we're currently not populating. This PR adds support for them. See #3770. === RUN TestAccContainerCluster_basic === PAUSE TestAccContainerCluster_basic === CONT TestAccContainerCluster_basic --- PASS: TestAccContainerCluster_basic (469.76s) PASS ok github.com/terraform-providers/terraform-provider-google/google 469.775s --- .../terraform/resources/resource_container_cluster.go.erb | 6 ++++++ .../terraform/tests/resource_container_cluster_test.go.erb | 3 +++ .../website/docs/r/container_cluster.html.markdown | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/third_party/terraform/resources/resource_container_cluster.go.erb b/third_party/terraform/resources/resource_container_cluster.go.erb index d364956e9db5..358216595b44 100644 --- a/third_party/terraform/resources/resource_container_cluster.go.erb +++ b/third_party/terraform/resources/resource_container_cluster.go.erb @@ -554,6 +554,11 @@ func resourceContainerCluster() *schema.Resource { Computed: true, }, + "services_ipv4_cidr": { + Type: schema.TypeString, + Computed: true, + }, + "ip_allocation_policy": { Type: schema.TypeList, MaxItems: 1, @@ -1034,6 +1039,7 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro d.Set("master_version", cluster.CurrentMasterVersion) d.Set("node_version", cluster.CurrentNodeVersion) d.Set("cluster_ipv4_cidr", cluster.ClusterIpv4Cidr) + d.Set("services_ipv4_cidr", cluster.ServicesIpv4Cidr) d.Set("description", cluster.Description) d.Set("enable_kubernetes_alpha", cluster.EnableKubernetesAlpha) d.Set("enable_legacy_abac", cluster.LegacyAbac.Enabled) diff --git a/third_party/terraform/tests/resource_container_cluster_test.go.erb b/third_party/terraform/tests/resource_container_cluster_test.go.erb index 0ec6d2bf64c1..76536d94a6f0 100644 --- a/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -88,6 +88,9 @@ func TestAccContainerCluster_basic(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccContainerCluster_basic(clusterName), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrSet("google_container_cluster.primary", "services_ipv4_cidr"), + ), }, { ResourceName: "google_container_cluster.primary", diff --git a/third_party/terraform/website/docs/r/container_cluster.html.markdown b/third_party/terraform/website/docs/r/container_cluster.html.markdown index adf286e8e29b..48dc2b3231fe 100644 --- a/third_party/terraform/website/docs/r/container_cluster.html.markdown +++ b/third_party/terraform/website/docs/r/container_cluster.html.markdown @@ -607,6 +607,11 @@ exported: [CIDR](http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation (e.g. `1.2.3.4/29`). +* `services_ipv4_cidr` - The IP address range of the Kubernetes services in this + cluster, in [CIDR](http:en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) + notation (e.g. `1.2.3.4/29`). Service addresses are typically put in the last + `/16` from the container CIDR. + ## Timeouts