Fix Google compute network forces new resource
This commit is contained in:
parent
1e7f10d3a3
commit
6ccfd8db93
|
@ -41,8 +41,9 @@ func resourceComputeNetwork() *schema.Resource {
|
||||||
/* Ideally this would default to true as per the API, but that would cause
|
/* 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
|
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 change. Perhaps we can bump this for a minor release bump rather than
|
||||||
a point release. */
|
a point release.
|
||||||
Default: false,
|
Default: false, */
|
||||||
|
ConflictsWith: []string{"ipv4_range"},
|
||||||
},
|
},
|
||||||
|
|
||||||
"description": &schema.Schema{
|
"description": &schema.Schema{
|
||||||
|
@ -64,19 +65,14 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro
|
||||||
|
|
||||||
//
|
//
|
||||||
// Possible modes:
|
// Possible modes:
|
||||||
// - 1 Legacy mode - Create a network in the legacy mode. ipv4_range is set. auto_create_subnetworks must be false
|
// - 1 Legacy mode - Create a network in the legacy mode. ipv4_range is set. auto_create_subnetworks must not be
|
||||||
// and not sent in request
|
// set (enforced by ConflictsWith schema attribute)
|
||||||
// - 2 Distributed Mode - Create a new generation network that supports subnetworks:
|
// - 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.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,
|
// - 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)
|
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
|
// Build the network parameter
|
||||||
network := &compute.Network{
|
network := &compute.Network{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
|
|
Loading…
Reference in New Issue