|
1 | 1 | ---
|
| 2 | +# ---------------------------------------------------------------------------- |
| 3 | +# |
| 4 | +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** |
| 5 | +# |
| 6 | +# ---------------------------------------------------------------------------- |
| 7 | +# |
| 8 | +# This file is automatically generated by Magic Modules and manual |
| 9 | +# changes will be clobbered when the file is regenerated. |
| 10 | +# |
| 11 | +# Please read more about how to change this file in |
| 12 | +# .github/CONTRIBUTING.md. |
| 13 | +# |
| 14 | +# ---------------------------------------------------------------------------- |
2 | 15 | layout: "google"
|
3 | 16 | page_title: "Google: google_compute_subnetwork"
|
4 |
| -sidebar_current: "docs-google-compute-subnetwork-x" |
| 17 | +sidebar_current: "docs-google-compute-subnetwork" |
5 | 18 | description: |-
|
6 |
| - Manages a subnetwork within GCE. |
| 19 | + A VPC network is a virtual version of the traditional physical networks |
| 20 | + that exist within and between physical data centers. |
7 | 21 | ---
|
8 | 22 |
|
9 | 23 | # google\_compute\_subnetwork
|
10 | 24 |
|
11 |
| -Manages a subnetwork within GCE. For more information see |
12 |
| -[the official documentation](https://cloud.google.com/compute/docs/vpc/#vpc_networks_and_subnets) |
13 |
| -and |
14 |
| -[API](https://cloud.google.com/compute/docs/reference/latest/subnetworks). |
| 25 | +A VPC network is a virtual version of the traditional physical networks |
| 26 | +that exist within and between physical data centers. A VPC network |
| 27 | +provides connectivity for your Compute Engine virtual machine (VM) |
| 28 | +instances, Container Engine containers, App Engine Flex services, and |
| 29 | +other network-related resources. |
15 | 30 |
|
16 |
| -## Example Usage |
| 31 | +Each GCP project contains one or more VPC networks. Each VPC network is a |
| 32 | +global entity spanning all GCP regions. This global VPC network allows VM |
| 33 | +instances and other resources to communicate with each other via internal, |
| 34 | +private IP addresses. |
17 | 35 |
|
18 |
| -```hcl |
19 |
| -resource "google_compute_subnetwork" "default-us-east1" { |
20 |
| - name = "default-us-east1" |
21 |
| - ip_cidr_range = "10.0.0.0/16" |
22 |
| - network = "${google_compute_network.default.self_link}" |
23 |
| - region = "us-east1" |
24 |
| -} |
25 |
| -
|
26 |
| -resource "google_compute_network" "default" { |
27 |
| - name = "test" |
28 |
| -} |
29 |
| -``` |
| 36 | +Each VPC network is subdivided into subnets, and each subnet is contained |
| 37 | +within a single region. You can have more than one subnet in a region for |
| 38 | +a given VPC network. Each subnet has a contiguous private RFC1918 IP |
| 39 | +space. You create instances, containers, and the like in these subnets. |
| 40 | +When you create an instance, you must create it in a subnet, and the |
| 41 | +instance draws its internal IP address from that subnet. |
30 | 42 |
|
31 |
| -## Argument Reference |
| 43 | +Virtual machine (VM) instances in a VPC network can communicate with |
| 44 | +instances in all other subnets of the same VPC network, regardless of |
| 45 | +region, using their RFC1918 private IP addresses. You can isolate portions |
| 46 | +of the network, even entire subnets, using firewall rules. |
32 | 47 |
|
33 |
| -The following arguments are supported: |
| 48 | +To get more information about Subnetwork, see: |
34 | 49 |
|
35 |
| -* `ip_cidr_range` - (Required) The IP address range that machines in this |
36 |
| - network are assigned to, represented as a CIDR block. |
37 |
| - |
38 |
| -* `name` - (Required) A unique name for the resource, required by GCE. |
39 |
| - Changing this forces a new resource to be created. |
40 |
| - |
41 |
| -* `network` - (Required) The network name or resource link to the parent |
42 |
| - network of this subnetwork. The parent network must have been created |
43 |
| - in custom subnet mode. |
44 |
| - |
45 |
| -- - - |
| 50 | +* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/subnetworks) |
| 51 | +* How-to Guides |
| 52 | + * [Private Google Access](https://cloud.google.com/vpc/docs/configure-private-google-access) |
| 53 | + * [Cloud Networking](https://cloud.google.com/vpc/docs/using-vpc) |
46 | 54 |
|
47 |
| -* `description` - (Optional) Description of this subnetwork. |
| 55 | +## Example Usage |
48 | 56 |
|
49 |
| -* `project` - (Optional) The ID of the project in which the resource belongs. If it |
50 |
| - is not provided, the provider project is used. |
| 57 | +```hcl |
| 58 | + resource "google_compute_network" "custom-test" { |
| 59 | + name = "test-network" |
| 60 | + auto_create_subnetworks = false |
| 61 | + } |
| 62 | +
|
| 63 | + resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" { |
| 64 | + name = "test-subnetwork" |
| 65 | + ip_cidr_range = "10.2.0.0/16" |
| 66 | + region = "us-central1" |
| 67 | + network = "${google_compute_network.custom-test.self_link}" |
| 68 | + secondary_ip_range { |
| 69 | + range_name = "tf-test-secondary-range-update1" |
| 70 | + ip_cidr_range = "192.168.10.0/24" |
| 71 | + } |
| 72 | + } |
| 73 | +``` |
51 | 74 |
|
52 |
| -* `region` - (Optional) The region this subnetwork will be created in. If |
53 |
| - unspecified, this defaults to the region configured in the provider. |
| 75 | +## Argument Reference |
54 | 76 |
|
55 |
| -* `private_ip_google_access` - (Optional) Whether the VMs in this subnet |
56 |
| - can access Google services without assigned external IP |
57 |
| - addresses. |
| 77 | +The following arguments are supported: |
58 | 78 |
|
59 |
| -* `enable_flow_logs` - (Optional, [Beta](/docs/providers/google/index.html#beta-features)) |
60 |
| - Set to `true` to enable [flow logs](https://cloud.google.com/vpc/docs/using-flow-logs) |
61 |
| - for this subnetwork. |
| 79 | +* `ip_cidr_range` - |
| 80 | + (Required) |
| 81 | + The range of internal addresses that are owned by this subnetwork. |
| 82 | + Provide this property when you create the subnetwork. For example, |
| 83 | + 10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and |
| 84 | + non-overlapping within a network. Only IPv4 is supported. |
| 85 | +* `name` - |
| 86 | + (Required) |
| 87 | + The name of the resource, provided by the client when initially |
| 88 | + creating the resource. The name must be 1-63 characters long, and |
| 89 | + comply with RFC1035. Specifically, the name must be 1-63 characters |
| 90 | + long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which |
| 91 | + means the first character must be a lowercase letter, and all |
| 92 | + following characters must be a dash, lowercase letter, or digit, |
| 93 | + except the last character, which cannot be a dash. |
| 94 | +* `network` - |
| 95 | + (Required) |
| 96 | + The network this subnet belongs to. |
| 97 | + Only networks that are in the distributed mode can have subnetworks. |
62 | 98 |
|
63 | 99 |
|
64 | 100 | - - -
|
65 | 101 |
|
66 |
| -* `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. |
| 102 | +* `description` - |
| 103 | + (Optional) |
| 104 | + An optional description of this resource. Provide this property when |
| 105 | + you create the resource. This field can be set only at resource |
| 106 | + creation time. |
| 107 | +* `enable_flow_logs` - |
| 108 | + (Optional) |
| 109 | + Whether to enable flow logging for this subnetwork. |
| 110 | +* `secondary_ip_range` - |
| 111 | + (Optional) |
| 112 | + An array of configurations for secondary IP ranges for VM instances |
| 113 | + contained in this subnetwork. The primary IP of such VM must belong |
| 114 | + to the primary ipCidrRange of the subnetwork. The alias IPs may belong |
| 115 | + to either primary or secondary ranges. Structure is documented below. |
| 116 | +* `private_ip_google_access` - |
| 117 | + (Optional) |
| 118 | + Whether the VMs in this subnet can access Google services without |
| 119 | + assigned external IP addresses. |
| 120 | +* `region` - |
| 121 | + (Optional) |
| 122 | + URL of the GCP region for this subnetwork. |
| 123 | +* `project` (Optional) The ID of the project in which the resource belongs. |
| 124 | + If it is not provided, the provider project is used. |
67 | 125 |
|
68 | 126 | The `secondary_ip_range` block supports:
|
69 |
| - |
70 |
| -* `range_name` - (Required) The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance. |
71 |
| - |
72 |
| -* `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. |
| 127 | +* `range_name` - |
| 128 | + (Required) |
| 129 | + The name associated with this subnetwork secondary range, used |
| 130 | + when adding an alias IP range to a VM instance. The name must |
| 131 | + be 1-63 characters long, and comply with RFC1035. The name |
| 132 | + must be unique within the subnetwork. |
| 133 | +* `ip_cidr_range` - |
| 134 | + (Required) |
| 135 | + The range of IP addresses belonging to this subnetwork secondary |
| 136 | + range. Provide this property when you create the subnetwork. |
| 137 | + Ranges must be unique and non-overlapping with all primary and |
| 138 | + secondary IP ranges within a network. Only IPv4 is supported. |
| 139 | + |
73 | 140 |
|
74 | 141 | ## Attributes Reference
|
75 | 142 |
|
76 |
| -In addition to the arguments listed above, the following computed attributes are |
77 |
| -exported: |
78 |
| - |
79 |
| -* `gateway_address` - The IP address of the gateway. |
| 143 | +In addition to the arguments listed above, the following computed attributes are exported: |
80 | 144 |
|
| 145 | +* `creation_timestamp` - |
| 146 | + Creation timestamp in RFC3339 text format. |
| 147 | +* `gateway_address` - |
| 148 | + The gateway address for default routes to reach destination addresses |
| 149 | + outside this subnetwork. |
| 150 | +* `fingerprint` - |
| 151 | + Fingerprint of this resource. This field is used internally during |
| 152 | + updates of this resource. |
81 | 153 | * `self_link` - The URI of the created resource.
|
82 | 154 |
|
| 155 | + |
83 | 156 | ## Timeouts
|
84 | 157 |
|
85 | 158 | This resource provides the following
|
86 | 159 | [Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
|
87 | 160 |
|
88 |
| -- `create` - Default is `6 minutes` |
89 |
| -- `update` - Default is `6 minutes` |
90 |
| -- `delete` - Default is `6 minutes` |
| 161 | +- `create` - Default is 6 minutes. |
| 162 | +- `update` - Default is 6 minutes. |
| 163 | +- `delete` - Default is 6 minutes. |
91 | 164 |
|
92 | 165 | ## Import
|
93 | 166 |
|
94 |
| -Subnetwork can be imported using the `region` and `name`, e.g. |
| 167 | +Subnetwork can be imported using any of these accepted formats: |
95 | 168 |
|
96 | 169 | ```
|
97 |
| -$ terraform import google_compute_subnetwork.default-us-east1 us-east1/default-us-east1 |
| 170 | +$ terraform import google_compute_subnetwork.default projects/{{project}}/regions/{{region}}/subnetworks/{{name}} |
| 171 | +$ terraform import google_compute_subnetwork.default {{region}}/{{name}} |
| 172 | +$ terraform import google_compute_subnetwork.default {{project}}/{{region}}/{{name}} |
| 173 | +$ terraform import google_compute_subnetwork.default {{name}} |
98 | 174 | ```
|
0 commit comments