Skip to content

Commit 5a48f4f

Browse files
committed
fix: support mysql engine_type
1 parent 8a5c9e0 commit 5a48f4f

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

tencentcloud/services/cdb/resource_tc_mysql_instance.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ func ResourceTencentCloudMysqlInstance() *schema.Resource {
226226
Default: MYSQL_SUPPORTS_ENGINE[len(MYSQL_SUPPORTS_ENGINE)-2],
227227
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.",
228228
},
229+
"engine_type": {
230+
Type: schema.TypeString,
231+
Optional: true,
232+
Computed: true,
233+
Description: "Instance engine type. The default value is `InnoDB`. Supported values include `InnoDB` and `RocksDB`.",
234+
},
229235
"upgrade_subversion": {
230236
Type: schema.TypeInt,
231237
Optional: true,
@@ -488,6 +494,16 @@ func mysqlMasterInstanceRoleSet(ctx context.Context, requestInter interface{}, d
488494
} else {
489495
requestByUse.EngineVersion = &engineVersion
490496
}
497+
498+
if stringInterface, ok := d.GetOk("engine_type"); ok {
499+
engineType := stringInterface.(string)
500+
if okByMonth {
501+
requestByMonth.EngineType = &engineType
502+
} else {
503+
requestByUse.EngineType = &engineType
504+
}
505+
}
506+
491507
if stringInterface, ok := d.GetOk("availability_zone"); ok {
492508
str := stringInterface.(string)
493509
if okByMonth {
@@ -873,6 +889,9 @@ func resourceTencentCloudMysqlInstanceRead(d *schema.ResourceData, meta interfac
873889
}
874890
_ = d.Set("project_id", int(*mysqlInfo.ProjectId))
875891
_ = d.Set("engine_version", mysqlInfo.EngineVersion)
892+
if mysqlInfo.EngineType != nil {
893+
_ = d.Set("engine_type", *mysqlInfo.EngineType)
894+
}
876895
if *mysqlInfo.WanStatus == 1 {
877896
_ = d.Set("internet_service", 1)
878897
_ = d.Set("internet_host", mysqlInfo.WanDomain)
@@ -1280,6 +1299,10 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
12801299
if d.HasChange("availability_zone") {
12811300
return fmt.Errorf("argument `availability_zone` cannot be modified for now")
12821301
}
1302+
1303+
if d.HasChange("engine_version") {
1304+
return fmt.Errorf("argument `engine_version` cannot be modified for now")
1305+
}
12831306
return nil
12841307
}
12851308

tencentcloud/services/cdb/resource_tc_mysql_instance_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ func TestAccTencentCloudMysqlInstanceResource_mysql8(t *testing.T) {
339339
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.mysql8", "id"),
340340
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "charge_type", "POSTPAID"),
341341
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_version", "8.0"),
342+
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_type", "InnoDB"),
342343
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "internet_service", "1"),
343344
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "slave_deploy_mode", "0"),
344345
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "first_slave_zone", "ap-guangzhou-4"),
@@ -362,6 +363,7 @@ func TestAccTencentCloudMysqlInstanceResource_mysql8(t *testing.T) {
362363
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.mysql8", "id"),
363364
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "charge_type", "POSTPAID"),
364365
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_version", "8.0"),
366+
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "engine_type", "InnoDB"),
365367
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "internet_service", "1"),
366368
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "slave_deploy_mode", "0"),
367369
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.mysql8", "first_slave_zone", "ap-guangzhou-4"),
@@ -628,9 +630,10 @@ resource "tencentcloud_mysql_instance" "mysql_master" {
628630
func testAccMysqlMasterInstance_mysql8(value string) string {
629631
return fmt.Sprintf(`
630632
resource "tencentcloud_mysql_instance" "mysql8" {
631-
internet_service = 1
632-
engine_version = "8.0"
633-
charge_type = "POSTPAID"
633+
internet_service = 1
634+
engine_version = "8.0"
635+
engine_type = "InnoDB"
636+
charge_type = "POSTPAID"
634637
root_password = "password123"
635638
slave_deploy_mode = 0
636639
first_slave_zone = "ap-guangzhou-4"

website/docs/r/mysql_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ The following arguments are supported:
144144
* `charge_type` - (Optional, String, ForceNew) Pay type of instance. Valid values:`PREPAID`, `POSTPAID`. Default is `POSTPAID`.
145145
* `cpu` - (Optional, Int) CPU cores.
146146
* `device_type` - (Optional, String) Specify device type, available values: `UNIVERSAL` (default), `EXCLUSIVE`, `BASIC`.
147+
* `engine_type` - (Optional, String) Instance engine type. The default value is `InnoDB`. Supported values include `InnoDB` and `RocksDB`.
147148
* `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.
148149
* `fast_upgrade` - (Optional, Int) Specify whether to enable fast upgrade when upgrade instance spec, available value: `1` - enabled, `0` - disabled.
149150
* `first_slave_zone` - (Optional, String) Zone information about first slave instance.

0 commit comments

Comments
 (0)