From 6ccfd8db9302ff3a0b09e5196bf2756559e46e20 Mon Sep 17 00:00:00 2001 From: Matt Morrison Date: Mon, 22 Feb 2016 21:55:42 +1300 Subject: [PATCH] Fix Google compute network forces new resource --- .../providers/google/resource_compute_network.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/builtin/providers/google/resource_compute_network.go b/builtin/providers/google/resource_compute_network.go index d57290103..573c72f40 100644 --- a/builtin/providers/google/resource_compute_network.go +++ b/builtin/providers/google/resource_compute_network.go @@ -41,8 +41,9 @@ func resourceComputeNetwork() *schema.Resource { /* Ideally this would default to true as per the API, but that would cause existing Terraform configs which have not been updated to report this as a change. Perhaps we can bump this for a minor release bump rather than - a point release. */ - Default: false, + a point release. + Default: false, */ + ConflictsWith: []string{"ipv4_range"}, }, "description": &schema.Schema{ @@ -64,19 +65,14 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro // // Possible modes: - // - 1 Legacy mode - Create a network in the legacy mode. ipv4_range is set. auto_create_subnetworks must be false - // and not sent in request + // - 1 Legacy mode - Create a network in the legacy mode. ipv4_range is set. auto_create_subnetworks must not be + // set (enforced by ConflictsWith schema attribute) // - 2 Distributed Mode - Create a new generation network that supports subnetworks: // - 2.a - Auto subnet mode - auto_create_subnetworks = true, Google will generate 1 subnetwork per region // - 2.b - Custom subnet mode - auto_create_subnetworks = false & ipv4_range not set, // - ipv4range := d.Get("ipv4_range").(string) autoCreateSubnetworks := d.Get("auto_create_subnetworks").(bool) - if ipv4range != "" && autoCreateSubnetworks { - return fmt.Errorf("Error: cannot define ipv4_range with auto_create_subnetworks = true.") - } - // Build the network parameter network := &compute.Network{ Name: d.Get("name").(string),