Skip to content

VPC Private Module

Creates a fully private VPC network with private-only subnets for GKE clusters and a management subnet for bastion hosts.

Features

  • Private Subnet: For GKE nodes with private Google access enabled
  • Management Subnet: For bastion hosts and management tools
  • No Public Subnets: Fully private network design
  • Optional NAT: Can enable NAT for management subnet if needed

Usage

hcl
module "vpc_private" {
  source = "../../modules/gcp/vpc-private"
  
  network_name          = "my-private-vpc"
  region                = "us-central1"
  private_subnet_cidr   = "10.0.1.0/24"
  management_subnet_cidr = "10.0.2.0/24"
  enable_management_nat = false  # Set to true if bastion needs internet access
}

Inputs

NameDescriptionTypeDefaultRequired
network_nameName of the VPC networkstringn/ayes
regionGCP regionstringn/ayes
private_subnet_cidrCIDR block for private subnet (GKE nodes)string"10.0.1.0/24"no
management_subnet_cidrCIDR block for management subnet (bastion host)string"10.0.2.0/24"no
enable_management_natEnable NAT for management subnetboolfalseno

Outputs

NameDescription
network_nameName of the VPC network
network_idID of the VPC network
private_subnet_nameName of the private subnet
private_subnet_idID of the private subnet
management_subnet_nameName of the management subnet
management_subnet_idID of the management subnet

Private Google Access

The private subnet has private_ip_google_access = true, which allows GKE nodes to access GCP services (Artifact Registry, Cloud Storage, etc.) without external IPs.

Use Cases

  • Private GKE clusters
  • Air-gapped or isolated environments
  • Compliance requirements for private-only networks
  • Bastion-hosted access patterns

Released under the MIT License.