google_compute_router_nat code example
Example: terraform cloud nat
resource "google_compute_network" "net" {
name = "my-network"
}
resource "google_compute_subnetwork" "subnet" {
name = "my-subnetwork"
network = google_compute_network.net.id
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
}
resource "google_compute_router" "router" {
name = "my-router"
region = google_compute_subnetwork.subnet.region
network = google_compute_network.net.id
bgp {
asn = 64514
}
}
resource "google_compute_router_nat" "nat" {
name = "my-router-nat"
router = google_compute_router.router.name
region = google_compute_router.router.region
nat_ip_allocate_option = "AUTO_ONLY"
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
log_config {
enable = true
filter = "ERRORS_ONLY"
}
}