Skip to content

Commit

Permalink
Remove ipv4range option
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisst committed Oct 11, 2018
1 parent 65d4116 commit 5389881
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
18 changes: 5 additions & 13 deletions google/resource_compute_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func resourceComputeNetwork() *schema.Resource {
Optional: true,
ForceNew: true,
// This needs to remain deprecated until the API is retired
Deprecated: "Please use google_compute_subnetwork resources instead.",
Removed: "Please use google_compute_subnetwork resources instead.",
},

"project": &schema.Schema{
Expand Down Expand Up @@ -89,9 +89,6 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro
// - 2.b - Custom subnet mode - auto_create_subnetworks = false & ipv4_range not set,
//
autoCreateSubnetworks := d.Get("auto_create_subnetworks").(bool)
if autoCreateSubnetworks && d.Get("ipv4_range").(string) != "" {
return fmt.Errorf("ipv4_range can't be set if auto_create_subnetworks is true.")
}

// Build the network parameter
network := &compute.Network{
Expand All @@ -107,14 +104,10 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro
network.RoutingConfig = routingConfig
}

if v, ok := d.GetOk("ipv4_range"); ok {
log.Printf("[DEBUG] Setting IPv4Range (%#v) for legacy network mode", v.(string))
network.IPv4Range = v.(string)
} else {
// custom subnet mode, so make sure AutoCreateSubnetworks field is included in request otherwise
// google will create a network in legacy mode.
network.ForceSendFields = []string{"AutoCreateSubnetworks"}
}
// make sure AutoCreateSubnetworks field is included in request otherwise
// google will create a network in legacy mode.
network.ForceSendFields = []string{"AutoCreateSubnetworks"}

log.Printf("[DEBUG] Network insert request: %#v", network)
op, err := config.clientCompute.Networks.Insert(
project, network).Do()
Expand Down Expand Up @@ -151,7 +144,6 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error

d.Set("routing_mode", routingConfig.RoutingMode)
d.Set("gateway_ipv4", network.GatewayIPv4)
d.Set("ipv4_range", network.IPv4Range)
d.Set("self_link", network.SelfLink)
d.Set("name", network.Name)
d.Set("description", network.Description)
Expand Down
4 changes: 0 additions & 4 deletions website/docs/r/compute_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ The following arguments are supported:
automatically. If set to false, a custom subnetted network will be created that
can support `google_compute_subnetwork` resources. Defaults to true.

* `ipv4_range` - (Optional) If set to a CIDR block, uses the legacy VPC API with the
specified range. This API is deprecated. If set, `auto_create_subnetworks` must be
explicitly set to false.

* `routing_mode` - (Optional) Sets the network-wide routing mode for Cloud Routers
to use. Accepted values are `"GLOBAL"` or `"REGIONAL"`. Defaults to `"REGIONAL"`.
Refer to the [Cloud Router documentation](https://cloud.google.com/router/docs/concepts/overview#dynamic-routing-mode)
Expand Down

0 comments on commit 5389881

Please sign in to comment.