Skip to content

Commit

Permalink
send enable_dynamic_port_allocation (#6938) (#4982)
Browse files Browse the repository at this point in the history
Co-authored-by: Edward Sun <sunedward@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun authored Dec 14, 2022
1 parent 4415ae5 commit 35b7caa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/6938.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed `google_compute_router_nat` so that `enable_dynamic_port_allocation` can be set to false
```
4 changes: 2 additions & 2 deletions google-beta/resource_compute_router_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions google-beta/resource_compute_router_nat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,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),
},
Expand Down

0 comments on commit 35b7caa

Please sign in to comment.