This submodule is part of the the terraform-google-network
module. It creates the individual vpc subnets.
It supports creating:
- Subnets within vpc network.
Basic usage of this submodule is as follows:
module "vpc" {
source = "terraform-google-modules/network/google//modules/subnets"
version = "~> 2.0.0"
project_id = "<PROJECT ID>"
network_name = "example-vpc"
subnets = [
{
subnet_name = "subnet-01"
subnet_ip = "10.10.10.0/24"
subnet_region = "us-west1"
},
{
subnet_name = "subnet-02"
subnet_ip = "10.10.20.0/24"
subnet_region = "us-west1"
subnet_private_access = "true"
subnet_flow_logs = "true"
description = "This subnet has a description"
purpose = "INTERNAL_HTTPS_LOAD_BALANCER"
role = "ACTIVE"
},
{
subnet_name = "subnet-03"
subnet_ip = "10.10.30.0/24"
subnet_region = "us-west1"
subnet_flow_logs = "true"
subnet_flow_logs_interval = "INTERVAL_10_MIN"
subnet_flow_logs_sampling = 0.7
subnet_flow_logs_metadata = "INCLUDE_ALL_METADATA"
subnet_flow_logs_filter_expr = "true"
}
]
secondary_ranges = {
subnet-01 = [
{
range_name = "subnet-01-secondary-01"
ip_cidr_range = "192.168.64.0/24"
},
]
subnet-02 = []
}
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
network_name | The name of the network where subnets will be created | string |
n/a | yes |
project_id | The ID of the project where subnets will be created | string |
n/a | yes |
secondary_ranges | Secondary ranges that will be used in some of the subnets | map(list(object({ range_name = string, ip_cidr_range = string }))) |
{} |
no |
subnets | The list of subnets being created | list(object({ |
n/a | yes |
Name | Description |
---|---|
subnets | The created subnet resources |
The subnets list contains maps, where each object represents a subnet. Each map has the following inputs (please see examples folder for additional references):
Name | Description | Type | Default | Required |
---|---|---|---|---|
subnet_name | The name of the subnet being created | string | - | yes |
subnet_ip | The IP and CIDR range of the subnet being created | string | - | yes |
subnet_region | The region where the subnet will be created | string | - | yes |
subnet_private_access | Whether this subnet will have private Google access enabled | string | "false" |
no |
subnet_private_ipv6_access | The private IPv6 google access type for the VMs in this subnet | string | - | no |
subnet_flow_logs | Whether the subnet will record and send flow log data to logging | string | "false" |
no |
subnet_flow_logs_interval | If subnet_flow_logs is true, sets the aggregation interval for collecting flow logs | string | "INTERVAL_5_SEC" |
no |
subnet_flow_logs_sampling | If subnet_flow_logs is true, set the sampling rate of VPC flow logs within the subnetwork | string | "0.5" |
no |
subnet_flow_logs_metadata | If subnet_flow_logs is true, configures whether metadata fields should be added to the reported VPC flow logs | string | "INCLUDE_ALL_METADATA" |
no |
subnet_flow_logs_filter | Export filter defining which VPC flow logs should be logged, see https://cloud.google.com/vpc/docs/flow-logs#filtering for formatting details | string | "true" |
no |
subnet_flow_logs_metadata_fields | List of metadata fields that should be added to reported logs. Can only be specified if VPC flow logs for this subnetwork is enabled and "metadata" is set to CUSTOM_METADATA. | any | - | no |
description | An optional description of this resource. Provide this property when you create the resource. This field can be set only at resource creation time | string | - | no |
purpose | The purpose of the subnet usage. Whether it is to be used as a regular subnet or for proxy or loadbalacing purposes, see https://cloud.google.com/vpc/docs/subnets#purpose for more details | string | "PRIVATE" |
no |
role | The role of the subnet when using it as a proxy or loadbalancer network. Whether it is to be used as the active or as a backup subnet, see https://cloud.google.com/load-balancing/docs/proxy-only-subnets#proxy_only_subnet_create for more details | string | - | no |
stack_type | IPV4_ONLY or IPV4_IPV6 for dual-stack networking |
string | - | no |
ipv6_access_type | INTERNAL or EXTERNAL . INTERNAL requires ULA be enabled on the VPC |
string | - | no |