» google_compute_network

Manages a VPC network or legacy network resource on GCP.

To get more information about Network, see:

» Example Usage - Network Basic

resource "google_compute_network" "vpc_network" {
  name = "vpc-network"
}

» Argument Reference

The following arguments are supported:

  • name - (Required) Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

  • description - (Optional) An optional description of this resource. The resource must be recreated to modify this field.

  • ipv4_range - (Optional, Deprecated) If this field is specified, a deprecated legacy network is created. You will no longer be able to create a legacy network on Feb 1, 2020. See the legacy network docs for more details. The range of internal addresses that are legal on this legacy network. This range is a CIDR specification, for example: 192.168.0.0/16. The resource must be recreated to modify this field.

  • auto_create_subnetworks - (Optional) When set to true, the network is created in "auto subnet mode" and it will create a subnet for each region automatically across the 10.128.0.0/9 address range. When set to false, the network is created in "custom subnet mode" so the user can explicitly connect subnetwork resources.

  • routing_mode - (Optional) The network-wide routing mode to use. If set to REGIONAL, this network's cloud routers will only advertise routes with subnetworks of this network in the same region as the router. If set to GLOBAL, this network's cloud routers will advertise routes with all subnetworks of this network, across regions.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

  • delete_default_routes_on_create: If set to true, default routes (0.0.0.0/0) will be deleted immediately after network creation. Defaults to false.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • gateway_ipv4 - The gateway address for default routing out of the network. This value is selected by GCP.
  • self_link - The URI of the created resource.

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

Network can be imported using any of these accepted formats:

$ terraform import google_compute_network.default projects/{{project}}/global/networks/{{name}}
$ terraform import google_compute_network.default {{project}}/{{name}}
$ terraform import google_compute_network.default {{name}}