Skip to content

Commit 29ee001

Browse files
jochenehretrkoster
authored andcommitted
Enable NAT Gateway for GCP
* currently we have to use external IPs for all VMs to enable outgoing traffic (`ephemeral_external_ip: true` in BOSH cloud-config) * to avoid allocating a large number of external IPs (and possibly leaving behind cost-incurring orphans), we should use a NAT gateway instead as on other infrastructures * this basic NAT configuration is taken from the Terraform manual: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_router_nat#example-usage---router-nat-basic
1 parent cd39e06 commit 29ee001

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

terraform/gcp/templates/cf_lb.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,26 @@ resource "google_compute_forwarding_rule" "cf-ws-http" {
233233
ip_protocol = "TCP"
234234
ip_address = "${google_compute_address.cf-ws.address}"
235235
}
236+
237+
resource "google_compute_router" "router" {
238+
name = "${var.env_id}-router"
239+
region = "${var.region}"
240+
network = "${google_compute_network.bbl-network.name}"
241+
242+
bgp {
243+
asn = 64514
244+
}
245+
}
246+
247+
resource "google_compute_router_nat" "nat" {
248+
name = "${var.env_id}-router-nat"
249+
router = "${google_compute_router.router.name}"
250+
region = "${var.region}"
251+
nat_ip_allocate_option = "AUTO_ONLY"
252+
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
253+
254+
log_config {
255+
enable = true
256+
filter = "ERRORS_ONLY"
257+
}
258+
}

0 commit comments

Comments
 (0)