From 6b1d4f9ddc88eaab5d128ff7d3a3aad2d56e3085 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 27 Mar 2020 12:31:20 -0700 Subject: [PATCH] =?UTF-8?q?Do=20not=20diffSuppress=20`port`=20when=20`port?= =?UTF-8?q?=5Fspecification`=20is=20not=20"US=E2=80=A6=20(#3316)=20(#5997)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Do not diffSuppress `port` when `port_specification` is "USED_NAME_PORT" * Formatting * Update health_check.erb Signed-off-by: Modular Magician --- .changelog/3316.txt | 3 +++ google/resource_compute_health_check.go | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changelog/3316.txt 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 } }