From 6a1719acfb72a2dc2f7b8e26efb9c5486c3c370a Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 14 Dec 2022 22:08:15 +0000 Subject: [PATCH] send enable_dynamic_port_allocation (#6938) Co-authored-by: Edward Sun Signed-off-by: Modular Magician --- .changelog/6938.txt | 3 +++ google/resource_compute_router_nat.go | 4 ++-- google/resource_compute_router_nat_test.go | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changelog/6938.txt diff --git a/.changelog/6938.txt b/.changelog/6938.txt new file mode 100644 index 00000000000..5f434162333 --- /dev/null +++ b/.changelog/6938.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: fixed `google_compute_router_nat` so that `enable_dynamic_port_allocation` can be set to false +``` diff --git a/google/resource_compute_router_nat.go b/google/resource_compute_router_nat.go index c72e9423a70..aee5609fe3c 100644 --- a/google/resource_compute_router_nat.go +++ b/google/resource_compute_router_nat.go @@ -513,7 +513,7 @@ func resourceComputeRouterNatCreate(d *schema.ResourceData, meta interface{}) er enableDynamicPortAllocationProp, err := expandNestedComputeRouterNatEnableDynamicPortAllocation(d.Get("enable_dynamic_port_allocation"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("enable_dynamic_port_allocation"); !isEmptyValue(reflect.ValueOf(enableDynamicPortAllocationProp)) && (ok || !reflect.DeepEqual(v, enableDynamicPortAllocationProp)) { + } else if v, ok := d.GetOkExists("enable_dynamic_port_allocation"); ok || !reflect.DeepEqual(v, enableDynamicPortAllocationProp) { obj["enableDynamicPortAllocation"] = enableDynamicPortAllocationProp } udpIdleTimeoutSecProp, err := expandNestedComputeRouterNatUdpIdleTimeoutSec(d.Get("udp_idle_timeout_sec"), d, config) @@ -776,7 +776,7 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er enableDynamicPortAllocationProp, err := expandNestedComputeRouterNatEnableDynamicPortAllocation(d.Get("enable_dynamic_port_allocation"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("enable_dynamic_port_allocation"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enableDynamicPortAllocationProp)) { + } else if v, ok := d.GetOkExists("enable_dynamic_port_allocation"); ok || !reflect.DeepEqual(v, enableDynamicPortAllocationProp) { obj["enableDynamicPortAllocation"] = enableDynamicPortAllocationProp } udpIdleTimeoutSecProp, err := expandNestedComputeRouterNatUdpIdleTimeoutSec(d.Get("udp_idle_timeout_sec"), d, config) diff --git a/google/resource_compute_router_nat_test.go b/google/resource_compute_router_nat_test.go index f63cb156131..47e283e4326 100644 --- a/google/resource_compute_router_nat_test.go +++ b/google/resource_compute_router_nat_test.go @@ -178,6 +178,14 @@ func TestAccComputeRouterNat_withPortAllocationMethods(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckComputeRouterNatDestroyProducer(t), Steps: []resource.TestStep{ + { + Config: testAccComputeRouterNatWithAllocationMethod(routerName, false, true), + }, + { + ResourceName: "google_compute_router_nat.foobar", + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccComputeRouterNatWithAllocationMethod(routerName, true, false), },