Skip to content

Commit b5ff068

Browse files
authored
fix(rdb): fix load balancer removal not detected (#3301)
1 parent e4fc9f0 commit b5ff068

File tree

3 files changed

+782
-522
lines changed

3 files changed

+782
-522
lines changed

internal/services/rdb/helpers.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,16 @@ func getIPConfigUpdate(d *schema.ResourceData, ipFieldName string) (ipamConfig *
106106

107107
return ipamConfig, staticConfig
108108
}
109+
110+
// LoadBalancerDiffSuppressFunc suppresses diff when load_balancer is not set
111+
func LoadBalancerDiffSuppressFunc(k, oldValue, newValue string, d *schema.ResourceData) bool {
112+
if !strings.HasPrefix(k, "load_balancer") {
113+
return false
114+
}
115+
116+
if _, exists := d.GetOk("load_balancer"); !exists {
117+
return true
118+
}
119+
120+
return false
121+
}

internal/services/rdb/instance.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ func ResourceInstance() *schema.Resource {
260260
Description: "Certificate of the database instance",
261261
},
262262
"load_balancer": {
263-
Type: schema.TypeList,
264-
Optional: true,
265-
Computed: true,
266-
Description: "Load balancer of the database instance",
263+
Type: schema.TypeList,
264+
Optional: true,
265+
Computed: true,
266+
MaxItems: 1,
267+
Description: "Load balancer of the database instance",
268+
DiffSuppressFunc: LoadBalancerDiffSuppressFunc,
267269
Elem: &schema.Resource{
268270
Schema: map[string]*schema.Schema{
269271
// Computed

internal/services/rdb/testdata/instance-endpoints.cassette.yaml

Lines changed: 763 additions & 518 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)