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

Mysql storage autogrow #4303

Merged
merged 6 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions azurerm/resource_arm_mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ func resourceArmMySqlServer() *schema.Resource {
}, true),
DiffSuppressFunc: suppress.CaseDifference,
},
"auto_grow": {
Type: schema.TypeString,
Optional: true,
Default: string(mysql.StorageAutogrowEnabled),
ValidateFunc: validation.StringInSlice([]string{
string(mysql.StorageAutogrowEnabled),
string(mysql.StorageAutogrowDisabled),
}, true),
r0bnet marked this conversation as resolved.
Show resolved Hide resolved
DiffSuppressFunc: suppress.CaseDifference,
r0bnet marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
},
Expand Down Expand Up @@ -409,11 +419,13 @@ func expandMySQLStorageProfile(d *schema.ResourceData) *mysql.StorageProfile {
backupRetentionDays := storageprofile["backup_retention_days"].(int)
geoRedundantBackup := storageprofile["geo_redundant_backup"].(string)
storageMB := storageprofile["storage_mb"].(int)
autoGrow := storageprofile["auto_grow"].(string)

return &mysql.StorageProfile{
BackupRetentionDays: utils.Int32(int32(backupRetentionDays)),
GeoRedundantBackup: mysql.GeoRedundantBackup(geoRedundantBackup),
StorageMB: utils.Int32(int32(storageMB)),
StorageAutogrow: mysql.StorageAutogrow(autoGrow),
}
}

Expand Down Expand Up @@ -450,5 +462,7 @@ func flattenMySQLStorageProfile(resp *mysql.StorageProfile) []interface{} {

values["geo_redundant_backup"] = string(resp.GeoRedundantBackup)

values["auto_grow"] = string(resp.StorageAutogrow)

return []interface{}{values}
}
64 changes: 64 additions & 0 deletions azurerm/resource_arm_mysql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,36 @@ func TestAccAzureRMMySQLServer_updateSKU(t *testing.T) {
})
}

func TestAccAzureRMMySQLServer_storageAutogrow(t *testing.T) {
resourceName := "azurerm_mysql_server.test"
ri := tf.AccRandTimeInt()
location := testLocation()
config := testAccAzureRMMySQLServer_basicFiveSeven(ri, location)
updatedConfig := testAccAzureRMMySQLServer_autogrow(ri, location)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMMySQLServerDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMySQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.auto_grow", "Enabled"),
),
},
{
Config: updatedConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMySQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.auto_grow", "Disabled"),
),
},
},
})
}

//

func testCheckAzureRMMySQLServerExists(resourceName string) resource.TestCheckFunc {
Expand Down Expand Up @@ -522,3 +552,37 @@ resource "azurerm_mysql_server" "test" {
}
`, rInt, location, rInt)
}

func testAccAzureRMMySQLServer_autogrow(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_mysql_server" "test" {
name = "acctestmysqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"

sku {
name = "GP_Gen5_2"
capacity = 2
tier = "GeneralPurpose"
family = "Gen5"
}

storage_profile {
storage_mb = 51200
backup_retention_days = 7
geo_redundant_backup = "Disabled"
auto_grow = "Disabled"
}

administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "5.7"
ssl_enforcement = "Enabled"
}
`, rInt, location, rInt)
}
2 changes: 2 additions & 0 deletions website/docs/r/mysql_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ The following arguments are supported:

* `geo_redundant_backup` - (Optional) Enable Geo-redundant or not for server backup. Valid values for this property are `Enabled` or `Disabled`, not supported for the `basic` tier.

* `auto_grow` - (Optional) Defines whether autogrow is enabled or disabled for the storage. Valid values are `Enabled` or `Disabled`.

## Attributes Reference

The following attributes are exported:
Expand Down