-
Notifications
You must be signed in to change notification settings - Fork 0
/
nat.tf
38 lines (34 loc) · 1.99 KB
/
nat.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
resource "google_compute_router_nat" "nats" {
for_each = {
for n in var.nats :
n.name => n
}
name = each.value.name
project = google_compute_router.router.project
router = google_compute_router.router.name
region = google_compute_router.router.region
nat_ip_allocate_option = lookup(each.value, "nat_ip_allocate_option", length(lookup(each.value, "nat_ips", [])) > 0 ? "MANUAL_ONLY" : "AUTO_ONLY")
source_subnetwork_ip_ranges_to_nat = lookup(each.value, "source_subnetwork_ip_ranges_to_nat", "ALL_SUBNETWORKS_ALL_IP_RANGES")
nat_ips = lookup(each.value, "nat_ips", null)
min_ports_per_vm = lookup(each.value, "min_ports_per_vm", null)
max_ports_per_vm = lookup(each.value, "max_ports_per_vm", null)
udp_idle_timeout_sec = lookup(each.value, "udp_idle_timeout_sec", null)
icmp_idle_timeout_sec = lookup(each.value, "icmp_idle_timeout_sec", null)
tcp_established_idle_timeout_sec = lookup(each.value, "tcp_established_idle_timeout_sec", null)
tcp_transitory_idle_timeout_sec = lookup(each.value, "tcp_transitory_idle_timeout_sec", null)
tcp_time_wait_timeout_sec = lookup(each.value, "tcp_time_wait_timeout_sec", null)
enable_endpoint_independent_mapping = lookup(each.value, "enable_endpoint_independent_mapping", null)
enable_dynamic_port_allocation = lookup(each.value, "enable_dynamic_port_allocation", null)
log_config {
enable = true
filter = lookup(lookup(each.value, "log_config", {}), "filter", "ALL")
}
dynamic "subnetwork" {
for_each = lookup(each.value, "subnetworks", [])
content {
name = subnetwork.value.name
source_ip_ranges_to_nat = subnetwork.value.source_ip_ranges_to_nat
secondary_ip_range_names = lookup(subnetwork.value, "secondary_ip_range_names", null)
}
}
}