Skip to content

Commit

Permalink
Fix explicitly setting the default network + subnetwork in GKE
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
rileykarson authored and modular-magician committed Apr 25, 2019
1 parent d2c85d7 commit cc77902
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,14 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
cluster.Network = network.RelativeLink()
}

// 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)
}

if v, ok := d.GetOk("subnetwork"); ok {
subnetwork, err := ParseSubnetworkFieldValue(v.(string), d, config)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions google/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,9 @@ resource "google_container_cluster" "primary" {
name = "%s"
location = "us-central1-a"
initial_node_count = 3
network = "default"
subnetwork = "default"
}`, name)
}

Expand Down

0 comments on commit cc77902

Please sign in to comment.