-
Notifications
You must be signed in to change notification settings - Fork 53
/
nat.tf
54 lines (50 loc) · 2.42 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 = coalesce(each.value.nat_ip_allocate_option, length(each.value.nat_ips) > 0 ? "MANUAL_ONLY" : "AUTO_ONLY")
source_subnetwork_ip_ranges_to_nat = coalesce(each.value.source_subnetwork_ip_ranges_to_nat, "ALL_SUBNETWORKS_ALL_IP_RANGES")
nat_ips = each.value.nat_ips
drain_nat_ips = each.value.drain_nat_ips
min_ports_per_vm = each.value.min_ports_per_vm
max_ports_per_vm = each.value.max_ports_per_vm
udp_idle_timeout_sec = each.value.udp_idle_timeout_sec
icmp_idle_timeout_sec = each.value.icmp_idle_timeout_sec
tcp_established_idle_timeout_sec = each.value.tcp_established_idle_timeout_sec
tcp_transitory_idle_timeout_sec = each.value.tcp_transitory_idle_timeout_sec
tcp_time_wait_timeout_sec = each.value.tcp_time_wait_timeout_sec
enable_endpoint_independent_mapping = each.value.enable_endpoint_independent_mapping
enable_dynamic_port_allocation = each.value.enable_dynamic_port_allocation
log_config {
enable = each.value.log_config.enable
filter = each.value.log_config.filter
}
dynamic "subnetwork" {
for_each = each.value.subnetworks
content {
name = subnetwork.value.name
source_ip_ranges_to_nat = subnetwork.value.source_ip_ranges_to_nat
secondary_ip_range_names = subnetwork.value.secondary_ip_range_names
}
}
}