Skip to content

Commit 5087808

Browse files
authored
fix: datasource redis_zone_config - replace mem_size with shard_memories (#875)
1 parent 2d38381 commit 5087808

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

tencentcloud/data_source_tc_redis_zone_config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ func dataSourceTencentRedisZoneConfig() *schema.Resource {
7474
Type: schema.TypeList,
7575
Elem: &schema.Schema{Type: schema.TypeInt},
7676
Computed: true,
77+
Deprecated: "It has been deprecated from version 1.26.0. Use `shard_memories` instead.",
7778
Description: "The memory volume of an available instance(in MB).",
7879
},
80+
"shard_memories": {
81+
Type: schema.TypeList,
82+
Description: "The memory volume list of an available instance shard(in MB).",
83+
Computed: true,
84+
Elem: &schema.Schema{Type: schema.TypeInt},
85+
},
7986
"redis_shard_nums": {
8087
Type: schema.TypeList,
8188
Computed: true,
@@ -160,7 +167,17 @@ func dataSourceTencentRedisZoneConfigRead(d *schema.ResourceData, meta interface
160167
memSizes = append(memSizes, temp*1024)
161168
}
162169

170+
shardMemories := make([]int64, 0, len(products.ShardSize))
171+
for _, size := range products.ShardSize {
172+
temp, err := strconv.ParseInt(*size, 10, 64)
173+
if err != nil {
174+
continue
175+
}
176+
shardMemories = append(shardMemories, temp*1024)
177+
}
178+
163179
zoneConfigures["mem_sizes"] = memSizes
180+
zoneConfigures["shard_memories"] = shardMemories
164181
zoneConfigures["type"] = REDIS_NAMES[*products.Type]
165182

166183
var redisShardNums []int64

tencentcloud/data_source_tc_redis_zone_config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestAccDataSourceRedisZoneConfig_basic(t *testing.T) {
2222
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.type"),
2323
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.version"),
2424
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.mem_sizes.#"),
25+
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.shard_memories.#"),
2526
),
2627
},
2728
{
@@ -33,6 +34,7 @@ func TestAccDataSourceRedisZoneConfig_basic(t *testing.T) {
3334
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.type_id"),
3435
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.version"),
3536
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.mem_sizes.#"),
37+
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.shard_memories.#"),
3638
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.redis_shard_nums.#"),
3739
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.redis_replicas_nums.#"),
3840
),

tencentcloud/resource_tc_redis_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func resourceTencentCloudRedisInstance() *schema.Resource {
168168
"mem_size": {
169169
Type: schema.TypeInt,
170170
Required: true,
171-
Description: "The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].mem_sizes`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding.",
171+
Description: "The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].shard_memories`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding.",
172172
},
173173
"vpc_id": {
174174
Type: schema.TypeString,

website/docs/d/redis_zone_config.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ The following arguments are supported:
3333
In addition to all arguments above, the following attributes are exported:
3434

3535
* `list` - A list of zone. Each element contains the following attributes:
36-
* `mem_sizes` - The memory volume of an available instance(in MB).
36+
* `mem_sizes` - (**Deprecated**) It has been deprecated from version 1.26.0. Use `shard_memories` instead. The memory volume of an available instance(in MB).
3737
* `redis_replicas_nums` - The support numbers of instance copies.
3838
* `redis_shard_nums` - The support numbers of instance shard.
39+
* `shard_memories` - The memory volume list of an available instance shard(in MB).
3940
* `type_id` - Instance type. Which redis type supports in this zone.
4041
* `type` - (**Deprecated**) It has been deprecated from version 1.33.1. Please use 'type_id' instead. Instance type. Available values: `master_slave_redis`, `master_slave_ckv`, `cluster_ckv`, `cluster_redis` and `standalone_redis`.
4142
* `version` - Version description of an available instance. Possible values: `Redis 3.2`, `Redis 4.0`.

website/docs/r/redis_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ resource "tencentcloud_redis_instance" "red1" {
6868
The following arguments are supported:
6969

7070
* `availability_zone` - (Required, ForceNew) The available zone ID of an instance to be created, please refer to `tencentcloud_redis_zone_config.list`.
71-
* `mem_size` - (Required) The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].mem_sizes`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding.
71+
* `mem_size` - (Required) The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].shard_memories`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding.
7272
* `auto_renew_flag` - (Optional, ForceNew) Auto-renew flag. 0 - default state (manual renewal); 1 - automatic renewal; 2 - explicit no automatic renewal.
7373
* `charge_type` - (Optional, ForceNew) The charge type of instance. Valid values: `PREPAID` and `POSTPAID`. Default value is `POSTPAID`. Note: TencentCloud International only supports `POSTPAID`. Caution that update operation on this field will delete old instances and create new with new charge type.
7474
* `force_delete` - (Optional) Indicate whether to delete Redis instance directly or not. Default is false. If set true, the instance will be deleted instead of staying recycle bin. Note: only works for `PREPAID` instance.

0 commit comments

Comments
 (0)