Skip to content

Commit

Permalink
Autogenerate Subnetwork. (hashicorp#1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
modular-magician authored and nat-henderson committed Jun 19, 2018
1 parent 801e1e1 commit 61f4291
Showing 1 changed file with 133 additions and 57 deletions.
190 changes: 133 additions & 57 deletions docs/r/compute_subnetwork.html.markdown
Original file line number Diff line number Diff line change
@@ -1,98 +1,174 @@
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
layout: "google"
page_title: "Google: google_compute_subnetwork"
sidebar_current: "docs-google-compute-subnetwork-x"
sidebar_current: "docs-google-compute-subnetwork"
description: |-
Manages a subnetwork within GCE.
A VPC network is a virtual version of the traditional physical networks
that exist within and between physical data centers.
---

# google\_compute\_subnetwork

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).
A VPC network is a virtual version of the traditional physical networks
that exist within and between physical data centers. A VPC network
provides connectivity for your Compute Engine virtual machine (VM)
instances, Container Engine containers, App Engine Flex services, and
other network-related resources.

## Example Usage
Each GCP project contains one or more VPC networks. Each VPC network is a
global entity spanning all GCP regions. This global VPC network allows VM
instances and other resources to communicate with each other via internal,
private IP addresses.

```hcl
resource "google_compute_subnetwork" "default-us-east1" {
name = "default-us-east1"
ip_cidr_range = "10.0.0.0/16"
network = "${google_compute_network.default.self_link}"
region = "us-east1"
}
resource "google_compute_network" "default" {
name = "test"
}
```
Each VPC network is subdivided into subnets, and each subnet is contained
within a single region. You can have more than one subnet in a region for
a given VPC network. Each subnet has a contiguous private RFC1918 IP
space. You create instances, containers, and the like in these subnets.
When you create an instance, you must create it in a subnet, and the
instance draws its internal IP address from that subnet.

## Argument Reference
Virtual machine (VM) instances in a VPC network can communicate with
instances in all other subnets of the same VPC network, regardless of
region, using their RFC1918 private IP addresses. You can isolate portions
of the network, even entire subnets, using firewall rules.

The following arguments are supported:
To get more information about Subnetwork, see:

* `ip_cidr_range` - (Required) The IP address range that machines in this
network are assigned to, represented as a CIDR block.

* `name` - (Required) A unique name for the resource, required by GCE.
Changing this forces a new resource to be created.

* `network` - (Required) The network name or resource link to the parent
network of this subnetwork. The parent network must have been created
in custom subnet mode.

- - -
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/subnetworks)
* How-to Guides
* [Private Google Access](https://cloud.google.com/vpc/docs/configure-private-google-access)
* [Cloud Networking](https://cloud.google.com/vpc/docs/using-vpc)

* `description` - (Optional) Description of this subnetwork.
## Example Usage

* `project` - (Optional) The ID of the project in which the resource belongs. If it
is not provided, the provider project is used.
```hcl
resource "google_compute_network" "custom-test" {
name = "test-network"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" {
name = "test-subnetwork"
ip_cidr_range = "10.2.0.0/16"
region = "us-central1"
network = "${google_compute_network.custom-test.self_link}"
secondary_ip_range {
range_name = "tf-test-secondary-range-update1"
ip_cidr_range = "192.168.10.0/24"
}
}
```

* `region` - (Optional) The region this subnetwork will be created in. If
unspecified, this defaults to the region configured in the provider.
## Argument Reference

* `private_ip_google_access` - (Optional) Whether the VMs in this subnet
can access Google services without assigned external IP
addresses.
The following arguments are supported:

* `enable_flow_logs` - (Optional, [Beta](/docs/providers/google/index.html#beta-features))
Set to `true` to enable [flow logs](https://cloud.google.com/vpc/docs/using-flow-logs)
for this subnetwork.
* `ip_cidr_range` -
(Required)
The range of internal addresses that are owned by this subnetwork.
Provide this property when you create the subnetwork. For example,
10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and
non-overlapping within a network. Only IPv4 is supported.
* `name` -
(Required)
The name of the resource, provided by the client when initially
creating the resource. 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.
* `network` -
(Required)
The network this subnet belongs to.
Only networks that are in the distributed mode can have subnetworks.


- - -

* `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.
* `description` -
(Optional)
An optional description of this resource. Provide this property when
you create the resource. This field can be set only at resource
creation time.
* `enable_flow_logs` -
(Optional)
Whether to enable flow logging for this subnetwork.
* `secondary_ip_range` -
(Optional)
An array of configurations for secondary IP ranges for VM instances
contained in this subnetwork. The primary IP of such VM must belong
to the primary ipCidrRange of the subnetwork. The alias IPs may belong
to either primary or secondary ranges. Structure is documented below.
* `private_ip_google_access` -
(Optional)
Whether the VMs in this subnet can access Google services without
assigned external IP addresses.
* `region` -
(Optional)
URL of the GCP region for this subnetwork.
* `project` (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

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.
* `range_name` -
(Required)
The name associated with this subnetwork secondary range, used
when adding an alias IP range to a VM instance. The name must
be 1-63 characters long, and comply with RFC1035. The name
must be unique within the subnetwork.
* `ip_cidr_range` -
(Required)
The range of IP addresses belonging to this subnetwork secondary
range. Provide this property when you create the subnetwork.
Ranges must be unique and non-overlapping with all primary and
secondary IP ranges within a network. Only IPv4 is supported.


## Attributes Reference

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

* `gateway_address` - The IP address of the gateway.
In addition to the arguments listed above, the following computed attributes are exported:

* `creation_timestamp` -
Creation timestamp in RFC3339 text format.
* `gateway_address` -
The gateway address for default routes to reach destination addresses
outside this subnetwork.
* `fingerprint` -
Fingerprint of this resource. This field is used internally during
updates of this resource.
* `self_link` - The URI of the created resource.


## Timeouts

This resource provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - Default is `6 minutes`
- `update` - Default is `6 minutes`
- `delete` - Default is `6 minutes`
- `create` - Default is 6 minutes.
- `update` - Default is 6 minutes.
- `delete` - Default is 6 minutes.

## Import

Subnetwork can be imported using the `region` and `name`, e.g.
Subnetwork can be imported using any of these accepted formats:

```
$ terraform import google_compute_subnetwork.default-us-east1 us-east1/default-us-east1
$ terraform import google_compute_subnetwork.default projects/{{project}}/regions/{{region}}/subnetworks/{{name}}
$ terraform import google_compute_subnetwork.default {{region}}/{{name}}
$ terraform import google_compute_subnetwork.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_subnetwork.default {{name}}
```

0 comments on commit 61f4291

Please sign in to comment.