Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: MySQL Flex Server Auto IOPS Scaling #23391

Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func dataSourceMysqlFlexibleServer() *pluginsdk.Resource {
Computed: true,
},

"iops_auto_scaling": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"iops": {
Type: pluginsdk.TypeInt,
Computed: true,
Expand Down Expand Up @@ -255,6 +260,7 @@ func flattenDataSourceArmServerStorage(storage *servers.Storage) []interface{} {
"size_gb": size,
"iops": iops,
"auto_grow_enabled": *storage.AutoGrow == servers.EnableStatusEnumEnabled,
"iops_auto_scaling": *storage.AutoIoScaling == servers.EnableStatusEnumEnabled,
},
}
}
Expand Down
15 changes: 14 additions & 1 deletion internal/services/mysql/mysql_flexible_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ func resourceMysqlFlexibleServer() *pluginsdk.Resource {
Default: true,
},

"iops_auto_scaling": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},

"iops": {
Type: pluginsdk.TypeInt,
Optional: true,
Expand Down Expand Up @@ -760,12 +766,18 @@ func expandArmServerStorage(inputs []interface{}) *servers.Storage {

input := inputs[0].(map[string]interface{})
autoGrow := servers.EnableStatusEnumDisabled
iopsAutoScaling := servers.EnableStatusEnumDisabled
if v := input["auto_grow_enabled"].(bool); v {
autoGrow = servers.EnableStatusEnumEnabled
}

if v := input["iops_auto_scaling"].(bool); v {
iopsAutoScaling = servers.EnableStatusEnumEnabled
}

storage := servers.Storage{
AutoGrow: &autoGrow,
AutoGrow: &autoGrow,
AutoIoScaling: &iopsAutoScaling,
}

if v := input["size_gb"].(int); v != 0 {
Expand Down Expand Up @@ -798,6 +810,7 @@ func flattenArmServerStorage(storage *servers.Storage) []interface{} {
"size_gb": size,
"iops": iops,
"auto_grow_enabled": *storage.AutoGrow == servers.EnableStatusEnumEnabled,
"iops_auto_scaling": *storage.AutoIoScaling == servers.EnableStatusEnumEnabled,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ resource "azurerm_mysql_flexible_server" "test" {
size_gb = 32
iops = 400
auto_grow_enabled = false
iops_auto_scaling = false
}

delegated_subnet_id = azurerm_subnet.test.id
Expand Down Expand Up @@ -989,9 +990,10 @@ resource "azurerm_mysql_flexible_server" "test" {
size_gb = %d
iops = %d
auto_grow_enabled = %t
iops_auto_scaling = %t
}
}
`, r.template(data), data.RandomInteger, sizeGB, iops, enabled)
`, r.template(data), data.RandomInteger, sizeGB, iops, enabled, enabled)
}

func (r MySqlFlexibleServerResource) failover(data acceptance.TestData, primaryZone string, standbyZone string) string {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/mysql_flexible_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ A `storage` block exports the following:

* `auto_grow_enabled` - Is Storage Auto Grow enabled?

* `iops_auto_scaling` - Is Iops Auto Scaling enabled?

* `iops` - The storage IOPS of the MySQL Flexible Server.

* `size_gb` - The max storage allowed for the MySQL Flexible Server.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/mysql_flexible_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ A `storage` block supports the following:

* `auto_grow_enabled` - (Optional) Should Storage Auto Grow be enabled? Defaults to `true`.

* `iops_auto_scaling` - (Optional) Should Iops Auto Scaling be enabled? Defaults to `false`.

* `iops` - (Optional) The storage IOPS for the MySQL Flexible Server. Possible values are between `360` and `20000`.

* `size_gb` - (Optional) The max storage allowed for the MySQL Flexible Server. Possible values are between `20` and `16384`.
Expand Down