VPC Networks Module for GCP
The module that creates networks and subnetworks on GCP.
It is primarily intended for Terraform 0.12.x users, because it offers possibility to conditionally handle either new or pre-existing networks/subnetworks without changing the source code. It is useful for 0.12 which doesn't allow conditional module instantiation.
This module is not strictly required for constructing inputs to be passed to other modules (including to vmseries or to autoscale modules). Any existing networks/subnetworks can work equally well, independent on how they were created.
For Terraform 0.13+, a viable alternative is to use Goggle-authored Terraform modules
and employ for_each
or count
parameters when needed.
Reference
Requirements
Name | Version |
---|---|
terraform | >= 1.2, < 2.0 |
~> 4.54 |
Providers
Name | Version |
---|---|
~> 4.54 |
Modules
No modules.
Resources
Name | Type |
---|---|
google_compute_firewall.this | resource |
google_compute_network.this | resource |
google_compute_subnetwork.this | resource |
google_compute_network.this | data source |
google_compute_subnetwork.this | data source |
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
allowed_ports | A list of ports to pass for the networks entries that do not have their own allowed_ports attribute. For example ["22", "443"]. Can also include ranges, for example ["80", "8080-8999"]. Empty list means to allow all. | list(string) | [] | no |
allowed_protocol | A protocol (TCP or UDP) to pass for the networks entries that do not have their own allowed_protocol attribute. | string | "all" | no |
networks | Map of networks, a minimal example: An advanced example: Full example: Terraform 0.12.x and 0.13.x limitation: the existing networks/subnetworks names should be static strings and not come from other resource objects.It is allowed from Terraform 0.14 onwards. | any | n/a | yes |
project_id | Project in which to create or look for VPCs and subnets | string | null | no |
region | GCP region for all the created subnetworks and for all the imported subnetworks. Set to null to use a default provider's region. To add subnetworks with another region use a separate instance of this module (and specify create_network=false to avoid creating a duplicate network). | string | null | no |
Outputs
Name | Description |
---|---|
networks | n/a |
networks_by_key | Map with network objects corresponding to input keys (or index if list was provided) of networks variable. |
subnetworks | n/a |
subnetworks_by_key | Map with subnetwork objects corresponding to input key (or index if list was provided) of networks variable. |