diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index cc16e3e5f547..b4809b5b9a08 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -13391,6 +13391,15 @@ objects: name: minPortsPerVm description: | Minimum number of ports allocated to a VM from this NAT. + - !ruby/object:Api::Type::Boolean + name: enableDynamicPortAllocation + description: | + Enable Dynamic Port Allocation. + If minPorts 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. + + Mutually exclusive with enableEndpointIndependentMapping. + default_value: false - !ruby/object:Api::Type::Integer name: udpIdleTimeoutSec description: | diff --git a/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb b/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb index 9bde6d215e37..f300475d927a 100644 --- a/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb @@ -171,7 +171,7 @@ func TestAccComputeRouterNat_withManualIpAndSubnetConfiguration(t *testing.T) { }) } -func TestAccComputeRouterNat_withDisabledIndependentEndpointMapping(t *testing.T) { +func TestAccComputeRouterNat_withPortAllocationMethods(t *testing.T) { t.Parallel() testId := randString(t, 10) @@ -183,7 +183,7 @@ func TestAccComputeRouterNat_withDisabledIndependentEndpointMapping(t *testing.T CheckDestroy: testAccCheckComputeRouterNatDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccComputeRouterNatWithDisabledIndependentEndpointMapping(routerName, true), + Config: testAccComputeRouterNatWithAllocationMethod(routerName, true, false), }, { ResourceName: "google_compute_router_nat.foobar", @@ -191,7 +191,7 @@ func TestAccComputeRouterNat_withDisabledIndependentEndpointMapping(t *testing.T ImportStateVerify: true, }, { - Config: testAccComputeRouterNatWithDisabledIndependentEndpointMapping(routerName, false), + Config: testAccComputeRouterNatWithAllocationMethod(routerName, false, false), }, { ResourceName: "google_compute_router_nat.foobar", @@ -199,7 +199,15 @@ func TestAccComputeRouterNat_withDisabledIndependentEndpointMapping(t *testing.T ImportStateVerify: true, }, { - Config: testAccComputeRouterNatWithDisabledIndependentEndpointMapping(routerName, true), + Config: testAccComputeRouterNatWithAllocationMethod(routerName, true, false), + }, + { + ResourceName: "google_compute_router_nat.foobar", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComputeRouterNatWithAllocationMethod(routerName, false, true), }, { ResourceName: "google_compute_router_nat.foobar", @@ -607,7 +615,7 @@ resource "google_compute_router_nat" "foobar" { `, routerName, routerName, routerName, routerName, routerName) } -func testAccComputeRouterNatWithDisabledIndependentEndpointMapping(routerName string, enabled bool) string { +func testAccComputeRouterNatWithAllocationMethod(routerName string, enableEndpointIndependentMapping, enableDynamicPortAllocation bool) string { return fmt.Sprintf(` resource "google_compute_network" "foobar" { name = "%s-net" @@ -647,8 +655,9 @@ resource "google_compute_router_nat" "foobar" { source_ip_ranges_to_nat = ["ALL_IP_RANGES"] } enable_endpoint_independent_mapping = %t + enable_dynamic_port_allocation = %t } -`, routerName, routerName, routerName, routerName, routerName, enabled) +`, routerName, routerName, routerName, routerName, routerName, enableEndpointIndependentMapping, enableDynamicPortAllocation) } <% unless version == 'ga' -%>