From 4688b0d33fd33aba51f4e3cbb5cd26efc4bc9b9c Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 26 Apr 2019 15:31:16 -0700 Subject: [PATCH] Fix explicitly setting the default network + subnetwork in GKE (#3492) Signed-off-by: Modular Magician --- google/resource_container_cluster.go | 8 ++++++++ google/resource_container_cluster_test.go | 3 +++ 2 files changed, 11 insertions(+) diff --git a/google/resource_container_cluster.go b/google/resource_container_cluster.go index 5933fe4b..ed6f61f6 100644 --- a/google/resource_container_cluster.go +++ b/google/resource_container_cluster.go @@ -634,6 +634,14 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er return err } + // When parsing a subnetwork by name, we expect region or zone to be set. + // Users may have set location to either value, so set that value. + if isZone(location) { + d.Set("zone", location) + } else { + d.Set("region", location) + } + clusterName := d.Get("name").(string) cluster := &containerBeta.Cluster{ diff --git a/google/resource_container_cluster_test.go b/google/resource_container_cluster_test.go index e1c84fc0..bcec6597 100644 --- a/google/resource_container_cluster_test.go +++ b/google/resource_container_cluster_test.go @@ -1416,6 +1416,9 @@ resource "google_container_cluster" "primary" { name = "%s" location = "us-central1-a" initial_node_count = 3 + + network = "default" + subnetwork = "default" }`, name) }