From d8ec351bf5e0d6aef9127ff924fc48f3f7902f91 Mon Sep 17 00:00:00 2001 From: adudzic <60104238+adudzic@users.noreply.github.com> Date: Tue, 5 Nov 2024 22:35:02 +0100 Subject: [PATCH] feat: add drain IPs option to NAT resource (#135) --- README.md | 2 +- nat.tf | 1 + variables.tf | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dabd9a..4f8000c 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Functional examples are included in the [examples](./examples/) directory. By de | bgp | BGP information specific to this router. |
object({| `null` | no | | description | An optional description of this resource | `string` | `null` | no | | name | Name of the router | `string` | n/a | yes | -| nats | NATs to deploy on this router. |
asn = string
advertise_mode = optional(string, "CUSTOM")
advertised_groups = optional(list(string))
advertised_ip_ranges = optional(list(object({
range = string
description = optional(string)
})), [])
keepalive_interval = optional(number)
})
list(object({| `[]` | no | +| nats | NATs to deploy on this router. |
name = string
nat_ip_allocate_option = optional(string)
source_subnetwork_ip_ranges_to_nat = optional(string)
nat_ips = optional(list(string), [])
min_ports_per_vm = optional(number)
max_ports_per_vm = optional(number)
udp_idle_timeout_sec = optional(number)
icmp_idle_timeout_sec = optional(number)
tcp_established_idle_timeout_sec = optional(number)
tcp_transitory_idle_timeout_sec = optional(number)
tcp_time_wait_timeout_sec = optional(number)
enable_endpoint_independent_mapping = optional(bool)
enable_dynamic_port_allocation = optional(bool)
log_config = optional(object({
enable = optional(bool, true)
filter = optional(string, "ALL")
}), {})
subnetworks = optional(list(object({
name = string
source_ip_ranges_to_nat = list(string)
secondary_ip_range_names = optional(list(string))
})), [])
}))
list(object({| `[]` | no | | network | A reference to the network to which this router belongs | `string` | n/a | yes | | project | The project ID to deploy to | `string` | n/a | yes | | region | Region where the router resides | `string` | n/a | yes | diff --git a/nat.tf b/nat.tf index 1d1f042..a48b137 100644 --- a/nat.tf +++ b/nat.tf @@ -27,6 +27,7 @@ resource "google_compute_router_nat" "nats" { 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 diff --git a/variables.tf b/variables.tf index 54ddd44..c8f9253 100644 --- a/variables.tf +++ b/variables.tf @@ -67,6 +67,7 @@ variable "bgp" { # - nat_ip_allocate_option (string, optional): How external IPs should be allocated for this NAT. Defaults to MANUAL_ONLY if nat_ips are set, else AUTO_ONLY. # - source_subnetwork_ip_ranges_to_nat (string, optional): How NAT should be configured per Subnetwork. Defaults to ALL_SUBNETWORKS_ALL_IP_RANGES. # - nat_ips (list(number), optional): Self-links of NAT IPs. +# - drain_nat_ips (list(number), optional): Self-links of NAT IPs to be drained. # - min_ports_per_vm (number, optional): Minimum number of ports allocated to a VM from this NAT. # - max_ports_per_vm (number, optional): Maximum number of ports allocated to a VM from this NAT. This field can only be set when enableDynamicPortAllocation is enabled. # - udp_idle_timeout_sec (number, optional): Timeout (in seconds) for UDP connections. Defaults to 30s if not set. @@ -87,6 +88,7 @@ variable "nats" { nat_ip_allocate_option = optional(string) source_subnetwork_ip_ranges_to_nat = optional(string) nat_ips = optional(list(string), []) + drain_nat_ips = optional(list(string), []) min_ports_per_vm = optional(number) max_ports_per_vm = optional(number) udp_idle_timeout_sec = optional(number)
name = string
nat_ip_allocate_option = optional(string)
source_subnetwork_ip_ranges_to_nat = optional(string)
nat_ips = optional(list(string), [])
drain_nat_ips = optional(list(string), [])
min_ports_per_vm = optional(number)
max_ports_per_vm = optional(number)
udp_idle_timeout_sec = optional(number)
icmp_idle_timeout_sec = optional(number)
tcp_established_idle_timeout_sec = optional(number)
tcp_transitory_idle_timeout_sec = optional(number)
tcp_time_wait_timeout_sec = optional(number)
enable_endpoint_independent_mapping = optional(bool)
enable_dynamic_port_allocation = optional(bool)
log_config = optional(object({
enable = optional(bool, true)
filter = optional(string, "ALL")
}), {})
subnetworks = optional(list(object({
name = string
source_ip_ranges_to_nat = list(string)
secondary_ip_range_names = optional(list(string))
})), [])
}))