Skip to content

Commit

Permalink
resource/alicloud_db_instance: fix_add_ModifyDBInstanceConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitiansheng0524 committed Dec 13, 2024
1 parent 6a9fd78 commit ead90e1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
21 changes: 20 additions & 1 deletion alicloud/resource_alicloud_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
},
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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) != "" {
Expand Down
20 changes: 20 additions & 0 deletions alicloud/resource_alicloud_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions alicloud/resource_alicloud_rds_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ 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": {
Type: schema.TypeString,
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"},
},
Expand Down
5 changes: 4 additions & 1 deletion website/docs/r/db_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ead90e1

Please sign in to comment.