Modular NAT Gateway on Google Compute Engine for Terraform.
module "nat" {
source = "GoogleCloudPlatform/nat-gateway/google"
region = "us-central1"
network = "default"
subnetwork = "default"
}
And add the tag ${module.nat.routing_tag_regional}
to your instances without external IPs to route outbound traffic through the nat gateway.
module "mig" {
source = "GoogleCloudPlatform/managed-instance-group/google"
version = "1.1.13"
region = "us-central1"
zone = "us-central1-a"
name = "testnat"
target_tags = ["${module.nat.routing_tag_regional}"]
network = "default"
subnetwork = "default"
}
module.nat-gateway
: The NAT gateway managed instance group module.google_compute_route.nat-gateway
: The route rule for the NAT gatway.google_compute_firewall.nat-gateway
: Firewall rule to allow traffic from the nat-REGION tagged instances.google_compute_address.default
: Static IP reservation for the NAT gateway instance.