Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3529.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_mysql_instance: support custom timeout parameters
```
18 changes: 11 additions & 7 deletions tencentcloud/services/cdb/resource_tc_mysql_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand All @@ -755,15 +759,15 @@ 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)
return resource.NonRetryableError(err)
})

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
}
}
Expand Down Expand Up @@ -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 {
Expand Down
21 changes: 18 additions & 3 deletions tencentcloud/services/cdb/resource_tc_mysql_instance.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -56,6 +56,11 @@ resource "tencentcloud_mysql_instance" "example" {
character_set_server = "utf8"
max_connections = "1000"
}

timeouts {
create = "30m"
delete = "30m"
}
}
```

Expand Down Expand Up @@ -87,6 +92,11 @@ resource "tencentcloud_mysql_instance" "example" {
character_set_server = "utf8"
max_connections = "1000"
}

timeouts {
create = "30m"
delete = "30m"
}
}
```

Expand Down Expand Up @@ -119,6 +129,11 @@ resource "tencentcloud_mysql_instance" "example" {
character_set_server = "utf8"
max_connections = "1000"
}

timeouts {
create = "30m"
delete = "30m"
}
}
```

Expand All @@ -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
```
23 changes: 19 additions & 4 deletions website/docs/r/mysql_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -67,6 +67,11 @@ resource "tencentcloud_mysql_instance" "example" {
character_set_server = "utf8"
max_connections = "1000"
}

timeouts {
create = "30m"
delete = "30m"
}
}
```

Expand Down Expand Up @@ -98,6 +103,11 @@ resource "tencentcloud_mysql_instance" "example" {
character_set_server = "utf8"
max_connections = "1000"
}

timeouts {
create = "30m"
delete = "30m"
}
}
```

Expand Down Expand Up @@ -130,6 +140,11 @@ resource "tencentcloud_mysql_instance" "example" {
character_set_server = "utf8"
max_connections = "1000"
}

timeouts {
create = "30m"
delete = "30m"
}
}
```

Expand Down Expand Up @@ -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
```

Loading