| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # 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. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Compute Engine" |
| description: |- |
| Manages a VPC network or legacy network resource on GCP. |
| --- |
| |
| # google\_compute\_network |
| |
| Manages a VPC network or legacy network resource on GCP. |
| |
| |
| To get more information about Network, see: |
| |
| * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/networks) |
| * How-to Guides |
| * [Official Documentation](https://cloud.google.com/vpc/docs/vpc) |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=network_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Network Basic |
| |
| |
| ```hcl |
| resource "google_compute_network" "vpc_network" { |
| name = "vpc-network" |
| } |
| ``` |
| ## Example Usage - Network Custom Mtu |
| |
| |
| ```hcl |
| resource "google_compute_network" "vpc_network" { |
| project = "my-project-name" |
| name = "vpc-network" |
| auto_create_subnetworks = true |
| mtu = 1460 |
| } |
| ``` |
| ## Example Usage - Network Custom Firewall Enforcement Order |
| |
| |
| ```hcl |
| resource "google_compute_network" "vpc_network" { |
| project = "my-project-name" |
| name = "vpc-network" |
| auto_create_subnetworks = true |
| network_firewall_policy_enforcement_order = "BEFORE_CLASSIC_FIREWALL" |
| } |
| ``` |
| |
| ## 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. |
| |
| * `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. |
| Possible values are: `REGIONAL`, `GLOBAL`. |
| |
| * `mtu` - |
| (Optional) |
| Maximum Transmission Unit in bytes. The default value is 1460 bytes. |
| The minimum value for this field is 1300 and the maximum value is 8896 bytes (jumbo frames). |
| Note that packets larger than 1500 bytes (standard Ethernet) can be subject to TCP-MSS clamping or dropped |
| with an ICMP `Fragmentation-Needed` message if the packets are routed to the Internet or other VPCs |
| with varying MTUs. |
| |
| * `enable_ula_internal_ipv6` - |
| (Optional) |
| Enable ULA internal ipv6 on this network. Enabling this feature will assign |
| a /48 from google defined ULA prefix fd20::/20. |
| |
| * `internal_ipv6_range` - |
| (Optional) |
| When enabling ula internal ipv6, caller optionally can specify the /48 range |
| they want from the google defined ULA prefix fd20::/20. The input must be a |
| valid /48 ULA IPv6 address and must be within the fd20::/20. Operation will |
| fail if the speficied /48 is already in used by another resource. |
| If the field is not speficied, then a /48 range will be randomly allocated from fd20::/20 and returned via this field. |
| |
| * `network_firewall_policy_enforcement_order` - |
| (Optional) |
| Set the order that Firewall Rules and Firewall Policies are evaluated. |
| Default value is `AFTER_CLASSIC_FIREWALL`. |
| Possible values are: `BEFORE_CLASSIC_FIREWALL`, `AFTER_CLASSIC_FIREWALL`. |
| |
| * `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` - (Optional) 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: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/global/networks/{{name}}` |
| |
| * `gateway_ipv4` - |
| The gateway address for default routing out of the network. This value |
| is selected by GCP. |
| |
| * `numeric_id` - |
| The unique identifier for the resource. This identifier is defined by the server. |
| * `self_link` - The URI of the created resource. |
| |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| Network can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/global/networks/{{name}}` |
| * `{{project}}/{{name}}` |
| * `{{name}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Network using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/global/networks/{{name}}" |
| to = google_compute_network.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Network can be imported using one of the formats above. For example: |
| |
| ``` |
| $ 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}} |
| ``` |
| |
| ## User Project Overrides |
| |
| This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |