From 0bfda843ff2ff795020a10f680e3fd8f33113527 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Fri, 19 Sep 2025 14:47:31 +0800 Subject: [PATCH 1/2] add --- .../cdb/resource_tc_mysql_instance.go | 18 +++++++++------ .../cdb/resource_tc_mysql_instance.md | 21 ++++++++++++++--- website/docs/r/mysql_instance.html.markdown | 23 +++++++++++++++---- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance.go b/tencentcloud/services/cdb/resource_tc_mysql_instance.go index 3e63360066..2de27509f7 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance.go @@ -339,6 +339,10 @@ func ResourceTencentCloudMysqlInstance() *schema.Resource { return []*schema.ResourceData{d}, nil }, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(20 * time.Minute), + Delete: schema.DefaultTimeout(20 * time.Minute), + }, } } @@ -711,7 +715,7 @@ func resourceTencentCloudMysqlInstanceCreate(d *schema.ResourceData, meta interf } } //internal version: replace setTag end, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation. - err := resource.Retry(7*tccommon.ReadRetryTimeout, func() *resource.RetryError { + err := resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { mysqlInfo, err := mysqlService.DescribeDBInstanceById(ctx, mysqlID) if err != nil { return resource.NonRetryableError(err) @@ -721,17 +725,17 @@ func resourceTencentCloudMysqlInstanceCreate(d *schema.ResourceData, meta interf return resource.NonRetryableError(err) } if *mysqlInfo.Status == MYSQL_STATUS_DELIVING { - return resource.RetryableError(fmt.Errorf("create mysql task status is MYSQL_STATUS_DELIVING(%d)", MYSQL_STATUS_DELIVING)) + return resource.RetryableError(fmt.Errorf("create mysql task status is MYSQL_STATUS_DELIVING(%d)", MYSQL_STATUS_DELIVING)) } if *mysqlInfo.Status == MYSQL_STATUS_RUNNING { return nil } - err = fmt.Errorf("create mysql task status is %v,we won't wait for it finish", *mysqlInfo.Status) + err = fmt.Errorf("create mysql task status is %v,we won't wait for it finish", *mysqlInfo.Status) return resource.NonRetryableError(err) }) if err != nil { - log.Printf("[CRITAL]%s create mysql task fail, reason:%s\n ", logId, err.Error()) + log.Printf("[CRITAL]%s create mysql task fail, reason:%s\n ", logId, err.Error()) return err } @@ -755,7 +759,7 @@ func resourceTencentCloudMysqlInstanceCreate(d *schema.ResourceData, meta interf return nil } if taskStatus == MYSQL_TASK_STATUS_INITIAL || taskStatus == MYSQL_TASK_STATUS_RUNNING { - return resource.RetryableError(fmt.Errorf("create account task status is %s", taskStatus)) + return resource.RetryableError(fmt.Errorf("create account task status is %s", taskStatus)) } err = fmt.Errorf("open internet service task status is %s,we won't wait for it finish ,it show message:%s", ",", message) @@ -763,7 +767,7 @@ func resourceTencentCloudMysqlInstanceCreate(d *schema.ResourceData, meta interf }) if err != nil { - log.Printf("[CRITAL]%s open internet service fail, reason:%s\n ", logId, err.Error()) + log.Printf("[CRITAL]%s open internet service fail, reason:%s\n ", logId, err.Error()) return err } } @@ -1633,7 +1637,7 @@ func resourceTencentCloudMysqlInstanceDelete(d *schema.ResourceData, meta interf payType := getPayType(d).(int) forceDelete := d.Get("force_delete").(bool) - err = resource.Retry(7*tccommon.ReadRetryTimeout, func() *resource.RetryError { + err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { mysqlInfo, err := mysqlService.DescribeDBInstanceById(ctx, d.Id()) if err != nil { diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance.md b/tencentcloud/services/cdb/resource_tc_mysql_instance.md index a678bca2f8..0673cb888e 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance.md +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance.md @@ -1,8 +1,8 @@ -Provides a mysql instance resource to create master database instances. +Provides a MySQL instance resource to create master database instances. ~> **NOTE:** If this mysql has readonly instance, the terminate operation of the mysql does NOT take effect immediately, maybe takes for several hours. so during that time, VPCs associated with that mysql instance can't be terminated also. -~> **NOTE:** The value of parameter `parameters` can be used with tencentcloud_mysql_parameter_list to obtain. +~> **NOTE:** The value of parameter `parameters` can be used with `tencentcloud_mysql_parameter_list` to obtain. Example Usage @@ -56,6 +56,11 @@ resource "tencentcloud_mysql_instance" "example" { character_set_server = "utf8" max_connections = "1000" } + + timeouts { + create = "30m" + delete = "30m" + } } ``` @@ -87,6 +92,11 @@ resource "tencentcloud_mysql_instance" "example" { character_set_server = "utf8" max_connections = "1000" } + + timeouts { + create = "30m" + delete = "30m" + } } ``` @@ -119,6 +129,11 @@ resource "tencentcloud_mysql_instance" "example" { character_set_server = "utf8" max_connections = "1000" } + + timeouts { + create = "30m" + delete = "30m" + } } ``` @@ -127,5 +142,5 @@ Import MySQL instance can be imported using the id, e.g. ``` -$ terraform import tencentcloud_mysql_instance.foo cdb-12345678 +$ terraform import tencentcloud_mysql_instance.example cdb-12345678 ``` \ No newline at end of file diff --git a/website/docs/r/mysql_instance.html.markdown b/website/docs/r/mysql_instance.html.markdown index c03c0b580a..604b3a2af1 100644 --- a/website/docs/r/mysql_instance.html.markdown +++ b/website/docs/r/mysql_instance.html.markdown @@ -4,16 +4,16 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_mysql_instance" sidebar_current: "docs-tencentcloud-resource-mysql_instance" description: |- - Provides a mysql instance resource to create master database instances. + Provides a MySQL instance resource to create master database instances. --- # tencentcloud_mysql_instance -Provides a mysql instance resource to create master database instances. +Provides a MySQL instance resource to create master database instances. ~> **NOTE:** If this mysql has readonly instance, the terminate operation of the mysql does NOT take effect immediately, maybe takes for several hours. so during that time, VPCs associated with that mysql instance can't be terminated also. -~> **NOTE:** The value of parameter `parameters` can be used with tencentcloud_mysql_parameter_list to obtain. +~> **NOTE:** The value of parameter `parameters` can be used with `tencentcloud_mysql_parameter_list` to obtain. ## Example Usage @@ -67,6 +67,11 @@ resource "tencentcloud_mysql_instance" "example" { character_set_server = "utf8" max_connections = "1000" } + + timeouts { + create = "30m" + delete = "30m" + } } ``` @@ -98,6 +103,11 @@ resource "tencentcloud_mysql_instance" "example" { character_set_server = "utf8" max_connections = "1000" } + + timeouts { + create = "30m" + delete = "30m" + } } ``` @@ -130,6 +140,11 @@ resource "tencentcloud_mysql_instance" "example" { character_set_server = "utf8" max_connections = "1000" } + + timeouts { + create = "30m" + delete = "30m" + } } ``` @@ -195,6 +210,6 @@ In addition to all arguments above, the following attributes are exported: MySQL instance can be imported using the id, e.g. ``` -$ terraform import tencentcloud_mysql_instance.foo cdb-12345678 +$ terraform import tencentcloud_mysql_instance.example cdb-12345678 ``` From 7c3bb68c25b39cc5ac260cd2b6d82748d1d913cf Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Fri, 19 Sep 2025 14:49:48 +0800 Subject: [PATCH 2/2] add --- .changelog/3529.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3529.txt diff --git a/.changelog/3529.txt b/.changelog/3529.txt new file mode 100644 index 0000000000..b29efb3cd3 --- /dev/null +++ b/.changelog/3529.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mysql_instance: support custom timeout parameters +```