diff --git a/.changelog/2779.txt b/.changelog/2779.txt new file mode 100644 index 0000000000..be048936e2 --- /dev/null +++ b/.changelog/2779.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mysql_instance: support mysql `engine_type`. +``` diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance.go b/tencentcloud/services/cdb/resource_tc_mysql_instance.go index 4516d39915..c8126d19e4 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance.go @@ -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, @@ -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 { @@ -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) @@ -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 } diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go b/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go index 588077ab8a..1df502c4b9 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go @@ -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"), @@ -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"), @@ -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" diff --git a/website/docs/r/mysql_instance.html.markdown b/website/docs/r/mysql_instance.html.markdown index a8354b9d7b..f6b5646a6a 100644 --- a/website/docs/r/mysql_instance.html.markdown +++ b/website/docs/r/mysql_instance.html.markdown @@ -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.