Skip to content

Commit b2104a6

Browse files
authored
fix(cdb): [122119363]Optimize the change issue of the replica_zone_id… (#3160)
* fix(cdb): [122119363]Optimize the change issue of the replica_zone_ids : command not found field in a single availability zone * feat: add changelog
1 parent fe8b341 commit b2104a6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.changelog/3160.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_redis_instance: Optimize the change issue of the `replica_zone_ids` field in a single availability zone.
3+
```

tencentcloud/services/crs/resource_tc_redis_instance.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ func resourceTencentCloudRedisInstanceRead(d *schema.ResourceData, meta interfac
641641
}
642642
}
643643

644-
if info.NodeSet != nil {
644+
if info.NodeSet != nil && len(info.NodeSet) > 0 {
645645
var zoneIds []int
646646
var nodeInfos []interface{}
647647
for i := range info.NodeSet {
@@ -670,6 +670,20 @@ func resourceTencentCloudRedisInstanceRead(d *schema.ResourceData, meta interfac
670670
if !zoneIdsEqual {
671671
_ = d.Set("replica_zone_ids", zoneIds)
672672
}
673+
674+
if replicaZonesOk && zoneIdsEqual {
675+
zoneIds := helper.InterfacesIntegers(replicaZones.([]interface{}))
676+
zoneIsSet := true
677+
for _, v := range zoneIds {
678+
if v != int(*info.ZoneId) {
679+
zoneIsSet = false
680+
break
681+
}
682+
}
683+
if zoneIsSet {
684+
_ = d.Set("replica_zone_ids", replicaZones)
685+
}
686+
}
673687
}
674688
//internal version: replace resourceTag begin, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
675689
tcClient := meta.(tccommon.ProviderMeta).GetAPIV3Conn()

0 commit comments

Comments
 (0)