diff --git a/.changelog/3560.txt b/.changelog/3560.txt new file mode 100644 index 0000000000..284313fba0 --- /dev/null +++ b/.changelog/3560.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mysql_readonly_instance: optmize code logic +``` diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance.go b/tencentcloud/services/cdb/resource_tc_mysql_instance.go index 8c7c16090b..16979e5e5c 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance.go @@ -182,6 +182,7 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema { "cluster_topology": { Type: schema.TypeList, Optional: true, + Computed: true, MaxItems: 1, Description: "Cluster Edition node topology configuration. Note: If you purchased a cluster edition instance, this parameter is required. You need to set the RW and RO node topology of the cluster edition instance. The RO node range is 1-5. Please set at least 1 RO node.", Elem: &schema.Resource{ @@ -325,7 +326,7 @@ func ResourceTencentCloudMysqlInstance() *schema.Resource { Optional: true, ValidateFunc: tccommon.ValidateAllowedIntValue([]int{0, 1}), Default: 0, - Description: "Availability zone deployment method. Available values: 0 - Single availability zone; 1 - Multiple availability zones.", + Description: "Availability zone deployment method. Available values: 0 - Single availability zone; 1 - Multiple availability zones. Readonly instance settings are not supported.", }, "first_slave_zone": { Type: schema.TypeString, diff --git a/tencentcloud/services/cdb/resource_tc_mysql_readonly_instance.go b/tencentcloud/services/cdb/resource_tc_mysql_readonly_instance.go index 9f941a2444..3b955bb90d 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_readonly_instance.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_readonly_instance.go @@ -64,8 +64,9 @@ func ResourceTencentCloudMysqlReadonlyInstance() *schema.Resource { Importer: &schema.ResourceImporter{ State: helper.ImportWithDefaultValue(map[string]interface{}{ - "prepaid_period": 1, - "force_delete": false, + "prepaid_period": 1, + "force_delete": false, + "slave_deploy_mode": 0, }), }, Schema: readonlyInstanceInfo, @@ -410,6 +411,9 @@ func resourceTencentCloudMysqlReadonlyInstanceRead(d *schema.ResourceData, meta _ = d.Set("ro_group_id", *roGroup.RoGroupId) } + // set no used fields to default value to fix diff + _ = d.Set("slave_deploy_mode", 0) + return nil } diff --git a/website/docs/r/mysql_instance.html.markdown b/website/docs/r/mysql_instance.html.markdown index 43ae3c9c8e..5c9d58c6d2 100644 --- a/website/docs/r/mysql_instance.html.markdown +++ b/website/docs/r/mysql_instance.html.markdown @@ -233,7 +233,7 @@ If it is not specified, it defaults to a universal instance. * `root_password` - (Optional, String) Password of root account. This parameter can be specified when you purchase master instances, but it should be ignored when you purchase read-only instances or disaster recovery instances. * `second_slave_zone` - (Optional, String) Zone information about second slave instance. * `security_groups` - (Optional, Set: [`String`]) Security groups to use. -* `slave_deploy_mode` - (Optional, Int) Availability zone deployment method. Available values: 0 - Single availability zone; 1 - Multiple availability zones. +* `slave_deploy_mode` - (Optional, Int) Availability zone deployment method. Available values: 0 - Single availability zone; 1 - Multiple availability zones. Readonly instance settings are not supported. * `slave_sync_mode` - (Optional, Int) Data replication mode. 0 - Async replication; 1 - Semisync replication; 2 - Strongsync replication. * `subnet_id` - (Optional, String) Private network ID. If `vpc_id` is set, this value is required. * `tags` - (Optional, Map) Instance tags.