From 34cb10eb3aff14ca90afaf1bd3a87f2b0ce44805 Mon Sep 17 00:00:00 2001 From: cts01586841 Date: Tue, 12 Nov 2024 15:47:46 +0800 Subject: [PATCH] resource/alicloud_db_instance:fix_Account_Modification --- alicloud/resource_alicloud_db_instance.go | 11 ++++++++++ .../resource_alicloud_db_instance_test.go | 20 +++++++++++++++++++ alicloud/resource_alicloud_rds_account.go | 4 ++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/alicloud/resource_alicloud_db_instance.go b/alicloud/resource_alicloud_db_instance.go index ba8bba6a9825..800f1e8a00cf 100644 --- a/alicloud/resource_alicloud_db_instance.go +++ b/alicloud/resource_alicloud_db_instance.go @@ -606,6 +606,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 +1428,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 +1718,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"] 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"}, },