Skip to content

fix(cdb): [119075711]support mysql engine_type #2779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2024
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/2779.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_mysql_instance: support mysql `engine_type`.
```
23 changes: 23 additions & 0 deletions tencentcloud/services/cdb/resource_tc_mysql_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ func ResourceTencentCloudMysqlInstance() *schema.Resource {
Default: MYSQL_SUPPORTS_ENGINE[len(MYSQL_SUPPORTS_ENGINE)-2],
Description: "The version number of the database engine to use. Supported versions include 5.5/5.6/5.7/8.0, and default is 5.7. Upgrade the instance engine version to support 5.6/5.7 and switch immediately.",
},
"engine_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Instance engine type. The default value is `InnoDB`. Supported values include `InnoDB` and `RocksDB`.",
},
"upgrade_subversion": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -488,6 +494,16 @@ func mysqlMasterInstanceRoleSet(ctx context.Context, requestInter interface{}, d
} else {
requestByUse.EngineVersion = &engineVersion
}

if stringInterface, ok := d.GetOk("engine_type"); ok {
engineType := stringInterface.(string)
if okByMonth {
requestByMonth.EngineType = &engineType
} else {
requestByUse.EngineType = &engineType
}
}

if stringInterface, ok := d.GetOk("availability_zone"); ok {
str := stringInterface.(string)
if okByMonth {
Expand Down Expand Up @@ -873,6 +889,9 @@ func resourceTencentCloudMysqlInstanceRead(d *schema.ResourceData, meta interfac
}
_ = d.Set("project_id", int(*mysqlInfo.ProjectId))
_ = d.Set("engine_version", mysqlInfo.EngineVersion)
if mysqlInfo.EngineType != nil {
_ = d.Set("engine_type", *mysqlInfo.EngineType)
}
if *mysqlInfo.WanStatus == 1 {
_ = d.Set("internet_service", 1)
_ = d.Set("internet_host", mysqlInfo.WanDomain)
Expand Down Expand Up @@ -1280,6 +1299,10 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
if d.HasChange("availability_zone") {
return fmt.Errorf("argument `availability_zone` cannot be modified for now")
}

if d.HasChange("engine_version") {
return fmt.Errorf("argument `engine_version` cannot be modified for now")
}
return nil
}

Expand Down
9 changes: 6 additions & 3 deletions tencentcloud/services/cdb/resource_tc_mysql_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func TestAccTencentCloudMysqlInstanceResource_mysql8(t *testing.T) {
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.mysql8", "id"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "charge_type", "POSTPAID"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_version", "8.0"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_type", "InnoDB"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "internet_service", "1"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "slave_deploy_mode", "0"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "first_slave_zone", "ap-guangzhou-4"),
Expand All @@ -362,6 +363,7 @@ func TestAccTencentCloudMysqlInstanceResource_mysql8(t *testing.T) {
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.mysql8", "id"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "charge_type", "POSTPAID"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_version", "8.0"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_type", "InnoDB"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "internet_service", "1"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "slave_deploy_mode", "0"),
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "first_slave_zone", "ap-guangzhou-4"),
Expand Down Expand Up @@ -628,9 +630,10 @@ resource "tencentcloud_mysql_instance" "mysql_master" {
func testAccMysqlMasterInstance_mysql8(value string) string {
return fmt.Sprintf(`
resource "tencentcloud_mysql_instance" "mysql8" {
internet_service = 1
engine_version = "8.0"
charge_type = "POSTPAID"
internet_service = 1
engine_version = "8.0"
engine_type = "InnoDB"
charge_type = "POSTPAID"
root_password = "password123"
slave_deploy_mode = 0
first_slave_zone = "ap-guangzhou-4"
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/mysql_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ The following arguments are supported:
* `charge_type` - (Optional, String, ForceNew) Pay type of instance. Valid values:`PREPAID`, `POSTPAID`. Default is `POSTPAID`.
* `cpu` - (Optional, Int) CPU cores.
* `device_type` - (Optional, String) Specify device type, available values: `UNIVERSAL` (default), `EXCLUSIVE`, `BASIC`.
* `engine_type` - (Optional, String) Instance engine type. The default value is `InnoDB`. Supported values include `InnoDB` and `RocksDB`.
* `engine_version` - (Optional, String) The version number of the database engine to use. Supported versions include 5.5/5.6/5.7/8.0, and default is 5.7. Upgrade the instance engine version to support 5.6/5.7 and switch immediately.
* `fast_upgrade` - (Optional, Int) Specify whether to enable fast upgrade when upgrade instance spec, available value: `1` - enabled, `0` - disabled.
* `first_slave_zone` - (Optional, String) Zone information about first slave instance.
Expand Down
Loading