README.md
May 24, 2022 ยท View on GitHub
Description
This module creates a new VPC network along with a cloud NAT, Router and common firewall rules. This module is based on submodules defined by the Cloud Foundation Toolkit.
The created cloud NAT (Network Address Translation) allows virtual machines without external IP addresses to create outbound connections to the internet. For more information see the docs.
The following firewall rules are created with the VPC network:
- Allow SSH access from the Cloud Console ("35.235.240.0/20").
- Allow traffic between nodes within the VPC
Primary and additional subnetworks
This module will, at minimum, provision a "primary" subnetwork in which most resources are expected to be provisioned. These are controlled by the following input variables:
var.subnetwork_nameandvar.subnetwork_sizevar.primary_subnetworkvar.additional_subnetworks
Both var.primary_subnetwork and var.additional_subnetworks behave
identically to the Cloud Foundation Toolkit subnets module with
the lone exception that the IP range for each subnet is constructed
automatically by calculating the most compact set of subnetworks. The size of
each individual subnetwork is specified with the new_bits key and the base of
the global VPC network is specified using var.network_address_range.
If explicitly supplied, var.primary_subnetwork defines all properties of the
primary subnetwork. If var.primary_subnetwork is left at its default value of
null, then a default primary subnetwork will be constructed from
var.subnetwork_name and var.subnetwork_size. If no value is supplied for
var.subnetwork_name, a default value is constructed from
var.deployment_name.
Additional subnetworks are optionally supplied explicitly with
var.additional_subnetworks.
Example
- source: modules/network/vpc
kind: terraform
id: network1
settings:
- deployment_name: $(vars.deployment_name)
This creates a new VPC network named based on the deployment_name variable
with _net appended. network_name can be set manually as well as part of the
settings.
NOTE:
deployment_namedoes not need to be set explicitly here. It would typically be inferred from the deployment variable of the same name. It is included here for clarity.
License
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Requirements
| Name | Version |
|---|---|
| terraform | >= 0.14.0 |
Providers
No providers.
Modules
| Name | Source | Version |
|---|---|---|
| cloud_router | terraform-google-modules/cloud-router/google | ~> 1.3 |
| firewall_rules | terraform-google-modules/network/google//modules/firewall-rules | ~> 5.0 |
| nat_ip_addresses | terraform-google-modules/address/google | ~> 3.1 |
| vpc | terraform-google-modules/network/google | ~> 5.0 |
Resources
No resources.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| additional_subnetworks | List of additional subnetworks in which to create resources. subnet_name (string, required, Name of subnet; will be replaced by var.subnetwork_name or its default value) subnet_region (string, required, will be replaced by var.region) new_bits (number, required, Additional CIDR bits to determine subnetwork size) subnet_private_access (bool, optional, Enable Private Access on subnetwork) subnet_flow_logs (map(string), optional, Configure Flow Logs see terraform-google-network module) description (string, optional, Description of Network) purpose (string, optional, related to Load Balancing) role (string, optional, related to Load Balancing) | list(map(string)) | [] | no |
| delete_default_internet_gateway_routes | If set, ensure that all routes within the network specified whose names begin with 'default-route' and with a next hop of 'default-internet-gateway' are deleted | bool | false | no |
| deployment_name | The name of the current deployment | string | n/a | yes |
| ips_per_nat | The number of IP addresses to allocate for each regional Cloud NAT (set to 0 to disable NAT) | number | 2 | no |
| network_address_range | IP address range (CIDR) for global network | string | "10.0.0.0/9" | no |
| network_description | An optional description of this resource (changes will trigger resource destroy/create) | string | "" | no |
| network_name | The name of the network to be created (if unsupplied, will default to "{deployment_name}-net") | string | null | no |
| network_routing_mode | The network routing mode (default "GLOBAL") | string | "GLOBAL" | no |
| primary_subnetwork | Primary (default) subnetwork in which to create resources. If null, a default value will be constructed. subnet_name (string, required, Name of subnet; will be replaced by var.subnetwork_name or its default value) subnet_region (string, required, will be replaced by var.region) new_bits (number, optional, Additional CIDR bits to determine subnetwork size; will default to var.subnetwork_size) subnet_private_access (bool, optional, Enable Private Access on subnetwork) subnet_flow_logs (map(string), optional, Configure Flow Logs see terraform-google-network module) description (string, optional, Description of Network) purpose (string, optional, related to Load Balancing) role (string, optional, related to Load Balancing) | map(string) | null | no |
| project_id | Project in which the HPC deployment will be created | string | n/a | yes |
| region | The default region for Cloud resources | string | n/a | yes |
| shared_vpc_host | Makes this project a Shared VPC host if 'true' (default 'false') | bool | false | no |
| subnetwork_name | The name of the network to be created (if unsupplied, will default to "{deployment_name}-primary-subnet") | string | null | no |
| subnetwork_size | The size, in CIDR bits, of the primary subnetwork unless explicitly supplied in var.primary_subnetwork | number | 15 | no |
Outputs
| Name | Description |
|---|---|
| nat_ips | the external IPs assigned to the NAT |
| network_name | The name of the network created |
| network_self_link | The URI of the VPC being created |
| subnetwork | The primary subnetwork object created by the input variable primary_subnetwork |
| subnetwork_address | The address range of the primary subnetwork |
| subnetwork_name | The name of the primary subnetwork |
| subnetwork_self_link | The self-link to the primary subnetwork |
| subnetworks | All subnetwork resources created by this module |