# VPC network and Cloud NAT A custom-mode VPC with its subnets and firewall rules, and outbound internet through Cloud NAT. Replaces a network, its subnetworks, a router, a NAT and each firewall rule. - `subnets` is a list of objects whose values are all strings, including `"true"` for `subnet_private_access`. - `network_name` is a name. Other resources want `module.network.network_self_link` or `network_id`; `subnets` is an output map keyed `"/"`. - `ingress_rules` replaces the deprecated `firewall_rules`. - The NAT module creates its router when `create_router = true`, and then needs `network`. - Set `name` on the NAT. Left unset it gets a random suffix. ```hcl variable "project_id" { type = string description = "Project to deploy into." } variable "region" { type = string description = "Region for regional resources." } module "network" { source = "terraform-google-modules/network/google" version = "18.3.1" project_id = var.project_id network_name = "workload" routing_mode = "REGIONAL" subnets = [ { subnet_name = "workload" subnet_ip = "10.10.0.0/24" subnet_region = var.region subnet_private_access = "true" subnet_flow_logs = "true" } ] ingress_rules = [ { name = "allow-health-checks" source_ranges = ["130.211.0.0/22", "35.191.0.0/16"] allow = [ { protocol = "tcp" ports = ["8080"] } ] } ] } module "nat" { source = "terraform-google-modules/cloud-nat/google" version = "7.1.0" project_id = var.project_id region = var.region name = "workload-nat" create_router = true router = "workload-router" network = module.network.network_self_link log_config_enable = true log_config_filter = "ERRORS_ONLY" } ```