2016-02-15 03:17:55 +00:00
---
layout: "google"
page_title: "Google: google_compute_subnetwork"
sidebar_current: "docs-google-compute-subnetwork"
description: |-
Manages a subnetwork within GCE.
---
# google\_compute\_subnetwork
2017-06-07 13:52:14 +00:00
Manages a subnetwork within GCE. For more information see
[the official documentation ](https://cloud.google.com/compute/docs/vpc/#vpc_networks_and_subnets )
and
[API ](https://cloud.google.com/compute/docs/reference/latest/subnetworks ).
2016-02-15 03:17:55 +00:00
## Example Usage
2017-04-17 10:17:54 +00:00
```hcl
2016-02-15 03:17:55 +00:00
resource "google_compute_subnetwork" "default-us-east1" {
2016-04-10 21:34:15 +00:00
name = "default-us-east1"
ip_cidr_range = "10.0.0.0/16"
network = "${google_compute_network.default.self_link}"
region = "us-east1"
2016-02-15 03:17:55 +00:00
}
2017-07-26 16:30:59 +00:00
resource "google_compute_network" "default" {
name = "test"
}
2016-02-15 03:17:55 +00:00
```
## Argument Reference
The following arguments are supported:
2016-04-10 21:34:15 +00:00
* `ip_cidr_range` - (Required) The IP address range that machines in this
network are assigned to, represented as a CIDR block.
2016-02-15 03:17:55 +00:00
* `name` - (Required) A unique name for the resource, required by GCE.
Changing this forces a new resource to be created.
2017-02-18 22:48:50 +00:00
* `network` - (Required) The network name or resource link to the parent
2016-09-03 09:51:20 +00:00
network of this subnetwork. The parent network must have been created
in custom subnet mode.
2016-03-31 10:37:17 +00:00
2016-04-10 21:34:15 +00:00
- - -
2016-02-15 03:17:55 +00:00
* `description` - (Optional) Description of this subnetwork.
2016-04-10 21:34:15 +00:00
* `project` - (Optional) The project in which the resource belongs. If it
is not provided, the provider project is used.
* `region` - (Optional) The region this subnetwork will be created in. If
unspecified, this defaults to the region configured in the provider.
2017-06-07 13:52:14 +00:00
* `private_ip_google_access` - (Optional) Whether the VMs in this subnet
2017-05-18 20:35:02 +00:00
can access Google services without assigned external IP
addresses.
2017-08-09 22:02:54 +00:00
- - -
2017-08-17 17:45:55 +00:00
* `secondary_ip_range` - (Optional, [Beta ](/docs/providers/google/index.html#beta-features )) An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. Structure is documented below.
2017-08-09 22:02:54 +00:00
The `secondary_ip_range` block supports:
* `range_name` - (Required) The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance.
* `ip_cidr_range` - (Required) The range of IP addresses belonging to this subnetwork secondary range. Ranges must be unique and non-overlapping with all primary and secondary IP ranges within a network.
2016-02-15 03:17:55 +00:00
## Attributes Reference
2016-04-10 21:34:15 +00:00
In addition to the arguments listed above, the following computed attributes are
exported:
2016-02-15 03:17:55 +00:00
* `gateway_address` - The IP address of the gateway.
2016-04-10 21:34:15 +00:00
* `self_link` - The URI of the created resource.
2017-07-26 16:30:59 +00:00
## Import
Subnetwork can be imported using the `region` and `name` , e.g.
```
$ terraform import google_compute_subnetwork.default-us-east1 us-east1/default-us-east1
```