From 98fc0f2ad2ae1217d6f8d3d2377f780f2254b64d Mon Sep 17 00:00:00 2001 From: mikatong Date: Tue, 5 Jul 2022 20:03:33 +0800 Subject: [PATCH 1/2] change replicas_read_only attribute --- tencentcloud/resource_tc_redis_instance.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tencentcloud/resource_tc_redis_instance.go b/tencentcloud/resource_tc_redis_instance.go index e1308c6f8c..c828b8f20f 100644 --- a/tencentcloud/resource_tc_redis_instance.go +++ b/tencentcloud/resource_tc_redis_instance.go @@ -165,8 +165,7 @@ func resourceTencentCloudRedisInstance() *schema.Resource { "replicas_read_only": { Type: schema.TypeBool, Optional: true, - ForceNew: true, - Default: false, + Computed: true, 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.", }, "mem_size": { @@ -298,7 +297,10 @@ func resourceTencentCloudRedisInstanceCreate(d *schema.ResourceData, meta interf chargeType := d.Get("charge_type").(string) autoRenewFlag := d.Get("auto_renew_flag").(int) chargeTypeID := REDIS_CHARGE_TYPE_ID[chargeType] - replicasReadonly := d.Get("replicas_read_only").(bool) + var replicasReadonly bool + if v, ok := d.GetOk("replicas_read_only"); ok { + replicasReadonly = v.(bool) + } var chargePeriod uint64 = 1 if chargeType == REDIS_CHARGE_TYPE_PREPAID { if period, ok := d.GetOk("prepaid_period"); ok { From a495c21f5b37dbcd8376f6f2ed7f805514fd260b Mon Sep 17 00:00:00 2001 From: mikatong Date: Tue, 5 Jul 2022 20:11:07 +0800 Subject: [PATCH 2/2] update doc --- website/docs/r/redis_instance.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/redis_instance.html.markdown b/website/docs/r/redis_instance.html.markdown index 40db4946a8..a3a10c10f8 100644 --- a/website/docs/r/redis_instance.html.markdown +++ b/website/docs/r/redis_instance.html.markdown @@ -81,7 +81,7 @@ The following arguments are supported: * `redis_replicas_num` - (Optional) The number of instance copies. This is not required for standalone and master slave versions. * `redis_shard_num` - (Optional) The number of instance shard, default is 1. This is not required for standalone and master slave versions. * `replica_zone_ids` - (Optional) ID of replica nodes available zone. This is not required for standalone and master slave versions. -* `replicas_read_only` - (Optional, ForceNew) 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. +* `replicas_read_only` - (Optional) 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. * `security_groups` - (Optional, ForceNew) ID of security group. If both vpc_id and subnet_id are not set, this argument should not be set either. * `subnet_id` - (Optional, ForceNew) Specifies which subnet the instance should belong to. * `tags` - (Optional) Instance tags.