Skip to content

Commit a3de149

Browse files
authored
fix: add validate value (#2305)
* fix: add validate value * fix:modify doc * fix: add 2305 changelog
1 parent 7ba9d18 commit a3de149

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

.changelog/2305.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: Fields `redis_shard_num`, `redis_replicas_num`, `mem_size` add enumeration values and value checks
3+
```

tencentcloud/resource_tc_redis_instance.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,18 @@ func resourceTencentCloudRedisInstance() *schema.Resource {
287287
Description: "Instance type. Available values reference data source `tencentcloud_redis_zone_config` or [document](https://intl.cloud.tencent.com/document/product/239/32069), toggle immediately when modified.",
288288
},
289289
"redis_shard_num": {
290-
Type: schema.TypeInt,
291-
Optional: true,
292-
Computed: true,
293-
Description: "The number of instance shard, default is 1. This is not required for standalone and master slave versions.",
290+
Type: schema.TypeInt,
291+
Optional: true,
292+
Computed: true,
293+
ValidateFunc: validateAllowedIntValue([]int{1, 3, 5, 8, 12, 16, 24, 32, 40, 48, 64, 80, 96, 128}),
294+
Description: "The number of instance shards; this parameter does not need to be configured for standard version instances; for cluster version instances, the number of shards ranges from: [`1`, `3`, `5`, `8`, `12`, `16`, `24 `, `32`, `40`, `48`, `64`, `80`, `96`, `128`].",
294295
},
295296
"redis_replicas_num": {
296-
Type: schema.TypeInt,
297-
Optional: true,
298-
Default: 1,
299-
Description: "The number of instance copies. This is not required for standalone and master slave versions and must equal to count of `replica_zone_ids`, Non-multi-AZ does not require `replica_zone_ids`.",
297+
Type: schema.TypeInt,
298+
Optional: true,
299+
Default: 1,
300+
ValidateFunc: validateAllowedIntValue([]int{1, 2, 3, 4, 5}),
301+
Description: "The number of instance copies. This is not required for standalone and master slave versions and must equal to count of `replica_zone_ids`, Non-multi-AZ does not require `replica_zone_ids`; Redis memory version 4.0, 5.0, 6.2 standard architecture and cluster architecture support the number of copies in the range [1, 2, 3, 4, 5]; Redis 2.8 standard version and CKV standard version only support 1 copy.",
300302
},
301303
"replica_zone_ids": {
302304
Type: schema.TypeList,
@@ -341,9 +343,10 @@ func resourceTencentCloudRedisInstance() *schema.Resource {
341343
Description: "Whether copy read-only is supported, Redis 2.8 Standard Edition and CKV Standard Edition do not support replica read-only, turn on replica read-only, the instance will automatically read and write separate, write requests are routed to the primary node, read requests are routed to the replica node, if you need to open replica read-only, the recommended number of replicas >=2.",
342344
},
343345
"mem_size": {
344-
Type: schema.TypeInt,
345-
Required: true,
346-
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.",
346+
Type: schema.TypeInt,
347+
Required: true,
348+
ValidateFunc: validateAllowedIntValue([]int{1024, 2048, 4096, 8192, 12288, 16384, 20480, 24576, 32768, 40960, 49152, 65536}),
349+
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.",
347350
},
348351
"vpc_id": {
349352
Type: schema.TypeString,

website/docs/r/redis_instance.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ The following arguments are supported:
253253
* `prepaid_period` - (Optional, Int) The tenancy (time unit is month) of the prepaid instance, NOTE: it only works when charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`.
254254
* `project_id` - (Optional, Int) Specifies which project the instance should belong to.
255255
* `recycle` - (Optional, Int) Original intranet IPv4 address retention time: unit: day, value range: `0`, `1`, `2`, `3`, `7`, `15`.
256-
* `redis_replicas_num` - (Optional, Int) The number of instance copies. This is not required for standalone and master slave versions and must equal to count of `replica_zone_ids`, Non-multi-AZ does not require `replica_zone_ids`.
257-
* `redis_shard_num` - (Optional, Int) The number of instance shard, default is 1. This is not required for standalone and master slave versions.
256+
* `redis_replicas_num` - (Optional, Int) The number of instance copies. This is not required for standalone and master slave versions and must equal to count of `replica_zone_ids`, Non-multi-AZ does not require `replica_zone_ids`; Redis memory version 4.0, 5.0, 6.2 standard architecture and cluster architecture support the number of copies in the range [1, 2, 3, 4, 5]; Redis 2.8 standard version and CKV standard version only support 1 copy.
257+
* `redis_shard_num` - (Optional, Int) The number of instance shards; this parameter does not need to be configured for standard version instances; for cluster version instances, the number of shards ranges from: [`1`, `3`, `5`, `8`, `12`, `16`, `24 `, `32`, `40`, `48`, `64`, `80`, `96`, `128`].
258258
* `replica_zone_ids` - (Optional, List: [`Int`]) ID of replica nodes available zone. This is not required for standalone and master slave versions. NOTE: Removing some of the same zone of replicas (e.g. removing 100001 of [100001, 100001, 100002]) will pick the first hit to remove.
259259
* `replicas_read_only` - (Optional, Bool) Whether copy read-only is supported, Redis 2.8 Standard Edition and CKV Standard Edition do not support replica read-only, turn on replica read-only, the instance will automatically read and write separate, write requests are routed to the primary node, read requests are routed to the replica node, if you need to open replica read-only, the recommended number of replicas >=2.
260260
* `security_groups` - (Optional, Set: [`String`]) ID of security group. If both vpc_id and subnet_id are not set, this argument should not be set either.

0 commit comments

Comments
 (0)