Skip to content

Commit

Permalink
Fix elbv2 target group read to workaround #2517
Browse files Browse the repository at this point in the history
  • Loading branch information
t0yv0 committed Jan 19, 2024
1 parent 367529d commit 9abc8be
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
46 changes: 32 additions & 14 deletions patches/0022-Fix-elbv2-target-group-read.patch
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Bradley <daniel@pulumi.com>
Date: Fri, 12 May 2023 10:55:42 +0100
Subject: [PATCH 22/36] Fix elbv2 target group read
From: Anton Tayanovskyy <anton@pulumi.com>
Date: Fri, 19 Jan 2024 17:36:47 -0500
Subject: [PATCH 40/40] Fix elbv2 target group read to workaround #2517

Workaround for https://github.com/pulumi/pulumi-aws/issues/2517
Don't return single empty map. Return empty list instead.

diff --git a/internal/service/elbv2/target_group.go b/internal/service/elbv2/target_group.go
index da35f69df6..d5f04f4647 100644
index 388edc5ec7..e61259bfa2 100644
--- a/internal/service/elbv2/target_group.go
+++ b/internal/service/elbv2/target_group.go
@@ -1221,6 +1221,12 @@ func flattenTargetGroupFailover(attributes []*elbv2.TargetGroupAttribute) []inte
}
@@ -562,15 +562,15 @@ func resourceTargetGroupRead(ctx context.Context, d *schema.ResourceData, meta i
return sdkdiag.AppendErrorf(diags, "reading ELBv2 Target Group (%s) attributes: %s", d.Id(), err)
}

- if err := d.Set("stickiness", []interface{}{flattenTargetGroupStickinessAttributes(attributes, protocol)}); err != nil {
+ if err := d.Set("stickiness", fix2517(flattenTargetGroupStickinessAttributes(attributes, protocol))); err != nil {
return sdkdiag.AppendErrorf(diags, "setting stickiness: %s", err)
}

- if err := d.Set("target_failover", []interface{}{flattenTargetGroupTargetFailoverAttributes(attributes, protocol)}); err != nil {
+ if err := d.Set("target_failover", fix2517(flattenTargetGroupTargetFailoverAttributes(attributes, protocol))); err != nil {
return sdkdiag.AppendErrorf(diags, "setting target_failover: %s", err)
}

- if err := d.Set("target_health_state", []interface{}{flattenTargetGroupTargetHealthStateAttributes(attributes, protocol)}); err != nil {
+ if err := d.Set("target_health_state", fix2517(flattenTargetGroupTargetHealthStateAttributes(attributes, protocol))); err != nil {
return sdkdiag.AppendErrorf(diags, "setting target_health_state: %s", err)
}

+ // Workaround for https://github.com/pulumi/pulumi-aws/issues/2517
+ // Don't return single empty map. Return empty list instead.
@@ -1385,3 +1385,13 @@ func runtimeValidations(d *schema.ResourceData, diags *diag.Diagnostics) {
}
}
}
+
+// Workaround for https://github.com/pulumi/pulumi-aws/issues/2517
+//
+// Don't return single empty map. Return empty list instead.
+func fix2517(m map[string]interface{}) []interface{} {
+ if len(m) == 0 {
+ return []interface{}{}
+ }
+
return []interface{}{m}
}

+ return []interface{}{m}
+}
2 changes: 1 addition & 1 deletion upstream
Submodule upstream updated 4755 files

0 comments on commit 9abc8be

Please sign in to comment.