Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate network fields #2235

Merged
merged 2 commits into from
Oct 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions google/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,43 +404,6 @@ func resourceComputeInstance() *schema.Resource {
Optional: true,
},

"network": &schema.Schema{
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Removed: "Please use network_interface",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"source": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"address": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},

"name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"internal_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"external_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
},
},

"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down
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