Skip to content

Commit

Permalink
resource/alicloud_db_instance: add new attributes:bursting_enabled an…
Browse files Browse the repository at this point in the history
…d modify sql_collector_config_value
  • Loading branch information
chaitiansheng0524 committed Jan 9, 2025
1 parent d4c008d commit 39c071e
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 147 deletions.
22 changes: 21 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 @@ -638,6 +643,10 @@ func resourceAliCloudDBInstance() *schema.Resource {
return d.Get("engine").(string) != "SQLServer"
},
},
"bursting_enabled": {
Type: schema.TypeBool,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -1455,6 +1464,13 @@ func resourceAliCloudDBInstanceUpdate(d *schema.ResourceData, meta interface{})
}
request["DBInstanceStorage"] = d.Get("instance_storage")

if d.HasChange("bursting_enabled") {
update = true
}
if v, ok := d.GetOkExists("bursting_enabled"); ok {
request["BurstingEnabled"] = v
}

if d.HasChange("serverless_config") {
update = true
if v, ok := d.GetOk("serverless_config"); ok {
Expand Down Expand Up @@ -1814,6 +1830,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"])
d.Set("pg_bouncer_enabled", instance["PGBouncerEnabled"])

// MySQL Serverless instance query PayType return SERVERLESS, need to be consistent with the participant.
Expand Down Expand Up @@ -2075,6 +2092,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.GetOkExists("bursting_enabled"); ok {
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
Loading

0 comments on commit 39c071e

Please sign in to comment.