Skip to content

Commit

Permalink
add port validation (#9231)
Browse files Browse the repository at this point in the history
Co-authored-by: Edward Sun <sunedward@google.com>
[upstream:a7f2e939fd74d50eb58182d6e3f378550a40edbe]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Oct 17, 2023
1 parent 0bed3d4 commit 7e671a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .changelog/9231.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed an error during the deletion when post was set to 0 on `google_compute_global_network_endpoint`
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
Expand Down Expand Up @@ -58,10 +59,11 @@ func ResourceComputeGlobalNetworkEndpoint() *schema.Resource {
Description: `The global network endpoint group this endpoint is part of.`,
},
"port": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: `Port number of the external endpoint.`,
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(1),
Description: `Port number of the external endpoint.`,
},
"fqdn": {
Type: schema.TypeString,
Expand Down Expand Up @@ -291,7 +293,7 @@ func resourceComputeGlobalNetworkEndpointDelete(d *schema.ResourceData, meta int
if err != nil {
return err
}
if portProp != "" {
if portProp != "" && portProp != 0 {
toDelete["port"] = portProp
}

Expand Down

0 comments on commit 7e671a1

Please sign in to comment.