From eeb6c4b18e42a43529a948e9d354b45fbc7b383c Mon Sep 17 00:00:00 2001 From: Erhan Cagirici Date: Mon, 21 Oct 2024 00:42:00 +0300 Subject: [PATCH] ignore non-effective diff for LBTargetGroup unhealthy_draining_interval defaulting Signed-off-by: Erhan Cagirici --- config/elbv2/config.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/elbv2/config.go b/config/elbv2/config.go index 312d099720..2358196390 100644 --- a/config/elbv2/config.go +++ b/config/elbv2/config.go @@ -119,6 +119,19 @@ func Configure(p *config.Provider) { //nolint:gocyclo s.Computed = false } r.LateInitializer.IgnoredFields = []string{"target_failover"} + r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, _ *terraform.InstanceState, _ *terraform.ResourceConfig) (*terraform.InstanceDiff, error) { + // skip no diff or destroy diffs + if diff == nil || diff.Empty() || diff.Destroy || diff.Attributes == nil { + return diff, nil + } + + // ignore diff due to defaulting in the TF schema + udiDiff, ok := diff.Attributes["target_health_state.0.unhealthy_draining_interval"] + if ok && udiDiff.Old == "" && udiDiff.New == "0" { + delete(diff.Attributes, "target_health_state.0.unhealthy_draining_interval") + } + return diff, nil + } }) p.AddResourceConfigurator("aws_lb_target_group_attachment", func(r *config.Resource) {