diff --git a/.changelog/3316.txt b/.changelog/3316.txt new file mode 100644 index 00000000000..dd9cfb8c944 --- /dev/null +++ b/.changelog/3316.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: Fixed an issue where `port` could not be removed from health checks +``` diff --git a/google/resource_compute_health_check.go b/google/resource_compute_health_check.go index 486bcff16a9..581f53dbe64 100644 --- a/google/resource_compute_health_check.go +++ b/google/resource_compute_health_check.go @@ -73,7 +73,7 @@ func healthCheckCustomizeDiff(diff *schema.ResourceDiff, v interface{}) error { return nil } -func portDiffSuppress(k, old, new string, _ *schema.ResourceData) bool { +func portDiffSuppress(k, old, new string, d *schema.ResourceData) bool { b := strings.Split(k, ".") if len(b) > 2 { attr := b[2] @@ -99,7 +99,8 @@ func portDiffSuppress(k, old, new string, _ *schema.ResourceData) bool { oldPort, _ := strconv.Atoi(old) newPort, _ := strconv.Atoi(new) - if int64(oldPort) == defaultPort && newPort == 0 { + portSpec := d.Get(b[0] + ".0.port_specification") + if int64(oldPort) == defaultPort && newPort == 0 && portSpec == "USE_FIXED_PORT" { return true } }