Skip to content

Latest commit

 

History

History
90 lines (72 loc) · 4.27 KB

File metadata and controls

90 lines (72 loc) · 4.27 KB

Terraform Network Module

This submodule is part of the the terraform-google-network module. It creates the individual vpc subnets.

It supports creating:

  • Subnets within vpc network.

Usage

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"
        },
        {
            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"
        }
    ]

    secondary_ranges = {
        subnet-01 = [
            {
                range_name    = "subnet-01-secondary-01"
                ip_cidr_range = "192.168.64.0/24"
            },
        ]

        subnet-02 = []
    }
}

Inputs

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 object <map> no
subnets The list of subnets being created list(map(string)) n/a yes

Outputs

Name Description
subnets The created subnet resources

Subnet Inputs

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_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