From ead90e1fffbdf202bde5596a240998a14beb579e Mon Sep 17 00:00:00 2001 From: cts01586841 Date: Fri, 13 Dec 2024 11:16:36 +0800 Subject: [PATCH] resource/alicloud_db_instance: fix_add_ModifyDBInstanceConfig --- alicloud/resource_alicloud_db_instance.go | 21 ++++++++++++++++++- .../resource_alicloud_db_instance_test.go | 20 ++++++++++++++++++ alicloud/resource_alicloud_rds_account.go | 4 ++-- website/docs/r/db_instance.html.markdown | 5 ++++- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/alicloud/resource_alicloud_db_instance.go b/alicloud/resource_alicloud_db_instance.go index ba8bba6a9825..92d1e31b8148 100644 --- a/alicloud/resource_alicloud_db_instance.go +++ b/alicloud/resource_alicloud_db_instance.go @@ -360,7 +360,12 @@ func resourceAliCloudDBInstance() *schema.Resource { Type: schema.TypeInt, Optional: true, ValidateFunc: IntInSlice([]int{30, 180, 365, 1095, 1825}), - Default: 30, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + if v, ok := d.GetOk("sql_collector_status"); ok && strings.ToLower(v.(string)) == "enabled" { + return false + } + return true + }, }, "resource_group_id": { Type: schema.TypeString, @@ -606,6 +611,11 @@ func resourceAliCloudDBInstance() *schema.Resource { Optional: true, ValidateFunc: StringInSlice([]string{"Up", "Down", "TempUpgrade", "Serverless"}, false), }, + "bursting_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, }, } } @@ -1423,6 +1433,11 @@ func resourceAliCloudDBInstanceUpdate(d *schema.ResourceData, meta interface{}) } request["DBInstanceStorage"] = d.Get("instance_storage") + if d.HasChange("bursting_enabled") { + update = true + } + request["BurstingEnabled"] = d.Get("bursting_enabled") + if d.HasChange("serverless_config") { update = true if v, ok := d.GetOk("serverless_config"); ok { @@ -1708,6 +1723,7 @@ func resourceAliCloudDBInstanceRead(d *schema.ResourceData, meta interface{}) er d.Set("zone_id", instance["ZoneId"]) d.Set("status", instance["DBInstanceStatus"]) d.Set("create_time", instance["CreationTime"]) + d.Set("bursting_enabled", instance["BurstingEnabled"]) // MySQL Serverless instance query PayType return SERVERLESS, need to be consistent with the participant. payType := instance["PayType"] @@ -1966,6 +1982,9 @@ func buildDBCreateRequest(d *schema.ResourceData, meta interface{}) (map[string] if v, ok := d.GetOk("port"); ok && v.(string) != "" { request["Port"] = v } + if v, ok := d.GetOk("bursting_enabled"); ok && v.(string) != "" { + request["BurstingEnabled"] = v + } if request["Engine"] == "MySQL" || request["Engine"] == "PostgreSQL" || request["Engine"] == "SQLServer" { if v, ok := d.GetOk("role_arn"); ok && v.(string) != "" { diff --git a/alicloud/resource_alicloud_db_instance_test.go b/alicloud/resource_alicloud_db_instance_test.go index b9258e1e84c6..356fd68643e0 100644 --- a/alicloud/resource_alicloud_db_instance_test.go +++ b/alicloud/resource_alicloud_db_instance_test.go @@ -241,6 +241,26 @@ func TestAccAliCloudRdsDBInstance_Mysql_8_0(t *testing.T) { }), ), }, + { + Config: testAccConfig(map[string]interface{}{ + "bursting_enabled": "true", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "bursting_enabled": "true", + }), + ), + }, + { + Config: testAccConfig(map[string]interface{}{ + "bursting_enabled": "false", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "bursting_enabled": "false", + }), + ), + }, { Config: testAccConfig(map[string]interface{}{ "db_instance_storage_type": "cloud_essd", diff --git a/alicloud/resource_alicloud_rds_account.go b/alicloud/resource_alicloud_rds_account.go index 598e60fe718a..d39b19c8f62b 100644 --- a/alicloud/resource_alicloud_rds_account.go +++ b/alicloud/resource_alicloud_rds_account.go @@ -46,7 +46,7 @@ func resourceAlicloudRdsAccount() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z][a-z0-9_]{0,61}[a-z0-9]$`), "The name can consist of lowercase letters, numbers, underscores, and must begin with letters and end with letters or numbers"), + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_]{0,61}[a-zA-Z0-9]$`), "The name can consist of letters, numbers, underscores, and must begin with letters and end with letters or numbers"), ConflictsWith: []string{"name"}, }, "name": { @@ -54,7 +54,7 @@ func resourceAlicloudRdsAccount() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z][a-z0-9_]{0,61}[a-z0-9]$`), "The name can consist of lowercase letters, numbers, underscores, and must begin with letters and end with letters or numbers"), + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_]{0,61}[a-zA-Z0-9]$`), "The name can consist of letters, numbers, underscores, and must begin with letters and end with letters or numbers"), Deprecated: "Field 'name' has been deprecated from provider version 1.120.0. New field 'account_name' instead.", ConflictsWith: []string{"account_name"}, }, diff --git a/website/docs/r/db_instance.html.markdown b/website/docs/r/db_instance.html.markdown index 1c949f4721be..d601c77c348c 100644 --- a/website/docs/r/db_instance.html.markdown +++ b/website/docs/r/db_instance.html.markdown @@ -759,7 +759,10 @@ The following arguments are supported: -> **NOTE:** This parameter is not required when you create an instance that runs MySQL, PostgreSQL, or SQL Server. You need to only specify the RoleARN parameter to create an instance that has cloud disk encryption enabled by using the obtained key ID. You can configure RAM authorization to require a RAM user to enable cloud disk encryption when the RAM user is used to create an instance. If cloud disk encryption is disabled during the instance creation, the creation operation fails. To complete the configuration, you can attach the following policy to the RAM user: {"Version":"1","Statement":[{"Effect":"Deny","Action":"rds:CreateDBInstance","Resource":"*","Condition":{"StringEquals":{"rds:DiskEncryptionRequired":"false"}}}]} * `direction` - (Optional, Available since v1.209.1) The instance configuration type. Valid values: ["Up", "Down", "TempUpgrade", "Serverless"] - +* `bursting_enabled` - (Optional, Available since 1.238.0) Specifies whether to enable the I/O burst feature of general + ESSDs. Valid values: + - true + - false * `node_id` - (Optional, Available since v1.213.1) The globally unique identifier (GUID) of the secondary instance. You can call the DescribeDBInstanceHAConfig operation to query the GUID of the secondary instance. * `force` - (Optional, ForceNew, Available since v1.213.1) Specifies whether to enable forcible switching. Valid values: