Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support enable_dynamic_port_allocation and max_ports_per_vm #20

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
steps:
- name: Checkout
# for security reasons we pin commit ids and not tags.
# actions/checkout@v3.0.2 -> 2541b1294d2704b0964813337f33b291d3f8596b
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
# actions/checkout@v4.1.4 -> 0ad4b8fadaa221de15dcec353f45205ec38ea70b
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0

Expand Down Expand Up @@ -65,8 +65,8 @@ jobs:
steps:
- name: Checkout
# for security reasons we pin commit ids and not tags.
# actions/checkout@v3.0.2 -> 2541b1294d2704b0964813337f33b291d3f8596b
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
# actions/checkout@v4.1.4 -> 0ad4b8fadaa221de15dcec353f45205ec38ea70b
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
steps:
- name: Checkout
# for security reasons we pin commit ids and not tags.
# actions/checkout@v3.0.2 -> 2541b1294d2704b0964813337f33b291d3f8596b
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
# actions/checkout@v4.1.4 -> 0ad4b8fadaa221de15dcec353f45205ec38ea70b
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0

Expand Down Expand Up @@ -69,8 +69,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
# actions/checkout@v3.0.2
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
# actions/checkout@v4.1.4
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0

Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
A [Terraform] module for [Google Cloud Platform (GCP)][gcp].

**_This module supports Terraform version 1
and is compatible with the Terraform Google Provider version 4._** and 5._**
and is compatible with the Terraform Google Provider version 4._** (4.28 and later) and 5._**

This module is part of our Infrastructure as Code (IaC) framework
that enables our users and customers to easily deploy and manage reusable,
Expand Down Expand Up @@ -207,10 +207,23 @@ See [variables.tf] and [examples/] for details and use-cases.

Self-links of NAT IPs. Only valid if `natIpAllocateOption` is set to MANUAL_ONLY.

- [**`enable_dynamic_port_allocation`**](#attr-nats-enable_dynamic_port_allocation): *(Optional `bool`)*<a name="attr-nats-enable_dynamic_port_allocation"></a>

Enable Dynamic Port Allocation.
If minPortsPerVm is set, minPortsPerVm must be set to a power of two greater than or equal to 32.
If minPortsPerVm is not set, a minimum of 32 ports will be allocated to a VM from this NAT config.
If maxPortsPerVm is set, maxPortsPerVm must be set to a power of two greater than minPortsPerVm.
If maxPortsPerVm is not set, a maximum of 65536 ports will be allocated to a VM from this NAT config.
Mutually exclusive with enableEndpointIndependentMapping.

- [**`min_ports_per_vm`**](#attr-nats-min_ports_per_vm): *(Optional `number`)*<a name="attr-nats-min_ports_per_vm"></a>

Minimum number of ports allocated to a VM from this NAT.

- [**`min_ports_per_vm`**](#attr-nats-min_ports_per_vm): *(Optional `number`)*<a name="attr-nats-min_ports_per_vm"></a>

Maximum number of ports allocated to a VM from this NAT.

- [**`udp_idle_timeout_sec`**](#attr-nats-udp_idle_timeout_sec): *(Optional `number`)*<a name="attr-nats-udp_idle_timeout_sec"></a>

Timeout (in seconds) for UDP connections.
Expand Down
21 changes: 20 additions & 1 deletion README.tfdoc.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ section {
A [Terraform] module for [Google Cloud Platform (GCP)][gcp].

**_This module supports Terraform version 1
and is compatible with the Terraform Google Provider version 4._** and 5._**
and is compatible with the Terraform Google Provider version 4._** (4.28 and later) and 5._**

This module is part of our Infrastructure as Code (IaC) framework
that enables our users and customers to easily deploy and manage reusable,
Expand Down Expand Up @@ -269,13 +269,32 @@ section {
END
}

attribute "enable_dynamic_port_allocation" {
type = bool
description = <<-END
Enable Dynamic Port Allocation.
If minPortsPerVm is set, minPortsPerVm must be set to a power of two greater than or equal to 32.
If minPortsPerVm is not set, a minimum of 32 ports will be allocated to a VM from this NAT config.
If maxPortsPerVm is set, maxPortsPerVm must be set to a power of two greater than minPortsPerVm.
If maxPortsPerVm is not set, a maximum of 65536 ports will be allocated to a VM from this NAT config.
Mutually exclusive with enableEndpointIndependentMapping.
END
}

attribute "min_ports_per_vm" {
type = number
description = <<-END
Minimum number of ports allocated to a VM from this NAT.
END
}

attribute "min_ports_per_vm" {
type = number
description = <<-END
Maximum number of ports allocated to a VM from this NAT.
END
}

attribute "udp_idle_timeout_sec" {
type = number
default = 30
Expand Down
4 changes: 3 additions & 1 deletion nat.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ resource "google_compute_router_nat" "nat" {

nat_ips = try(each.value.nat_ips, null)

min_ports_per_vm = try(each.value.min_ports_per_vm, null)
enable_dynamic_port_allocation = try(each.value.enable_dynamic_port_allocation, null)
min_ports_per_vm = try(each.value.min_ports_per_vm, null)
max_ports_per_vm = try(each.value.max_ports_per_vm, null)

udp_idle_timeout_sec = try(each.value.idle_timeout_sec, 30)
icmp_idle_timeout_sec = try(each.value.icmp_idle_timeout_sec, 30)
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 3.50, < 6"
version = ">= 4.28, < 6"
}
}
}
Loading