diff --git a/azurerm/resource_arm_mariadb_server.go b/azurerm/resource_arm_mariadb_server.go index 91e0bb8738d4..a3bb07340cb4 100644 --- a/azurerm/resource_arm_mariadb_server.go +++ b/azurerm/resource_arm_mariadb_server.go @@ -153,6 +153,16 @@ func resourceArmMariaDbServer() *schema.Resource { string(mariadb.Disabled), }, false), }, + + "auto_grow": { + Type: schema.TypeString, + Optional: true, + Default: string(mariadb.StorageAutogrowEnabled), + ValidateFunc: validation.StringInSlice([]string{ + string(mariadb.StorageAutogrowEnabled), + string(mariadb.StorageAutogrowDisabled), + }, false), + }, }, }, }, @@ -400,11 +410,13 @@ func expandAzureRmMariaDbStorageProfile(d *schema.ResourceData) *mariadb.Storage backupRetentionDays := storageprofile["backup_retention_days"].(int) geoRedundantBackup := storageprofile["geo_redundant_backup"].(string) storageMB := storageprofile["storage_mb"].(int) + autoGrow := storageprofile["auto_grow"].(string) return &mariadb.StorageProfile{ BackupRetentionDays: utils.Int32(int32(backupRetentionDays)), GeoRedundantBackup: mariadb.GeoRedundantBackup(geoRedundantBackup), StorageMB: utils.Int32(int32(storageMB)), + StorageAutogrow: mariadb.StorageAutogrow(autoGrow), } } @@ -449,5 +461,7 @@ func flattenMariaDbStorageProfile(storage *mariadb.StorageProfile) []interface{} values["geo_redundant_backup"] = string(storage.GeoRedundantBackup) + values["auto_grow"] = string(storage.StorageAutogrow) + return []interface{}{values} } diff --git a/azurerm/resource_arm_mariadb_server_test.go b/azurerm/resource_arm_mariadb_server_test.go index 9cace7b2a28f..8d4e8acbfc0b 100644 --- a/azurerm/resource_arm_mariadb_server_test.go +++ b/azurerm/resource_arm_mariadb_server_test.go @@ -262,7 +262,35 @@ func TestAccAzureRMMariaDbServer_updateSKU(t *testing.T) { }) } -// +func TestAccAzureRMMariaDbServer_storageAutogrow(t *testing.T) { + resourceName := "azurerm_mariadb_server.test" + ri := tf.AccRandTimeInt() + location := testLocation() + config := testAccAzureRMMariaDbServer_basic(ri, location) + updatedConfig := testAccAzureRMMariaDbServer_storageAutogrowUpdated(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMMariaDbServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.auto_grow", "Enabled"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMariaDbServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.auto_grow", "Disabled"), + ), + }, + }, + }) +} func testCheckAzureRMMariaDbServerExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { @@ -582,3 +610,37 @@ resource "azurerm_mariadb_server" "test" { } `, rInt, location, rInt) } + +func testAccAzureRMMariaDbServer_storageAutogrowUpdated(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_mariadb_server" "test" { + name = "acctestmariadbsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "B_Gen5_2" + capacity = 2 + tier = "Basic" + 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 = "10.2" + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} diff --git a/website/docs/r/mariadb_server.html.markdown b/website/docs/r/mariadb_server.html.markdown index ecdeb8d5c1db..697ed6791a3f 100644 --- a/website/docs/r/mariadb_server.html.markdown +++ b/website/docs/r/mariadb_server.html.markdown @@ -36,6 +36,7 @@ resource "azurerm_mariadb_server" "test" { storage_mb = 5120 backup_retention_days = 7 geo_redundant_backup = "Disabled" + storage_autogrow = "Disabled" } administrator_login = "mariadbadmin" @@ -91,6 +92,8 @@ A `storage_profile` block supports the following: * `geo_redundant_backup` - (Optional) Enable Geo-redundant or not for server backup. Valid values for this property are `Enabled` or `Disabled`. +* `auto_grow` - (Optional) Defines whether autogrow is enabled or disabled for the storage. Valid values are `Enabled` or `Disabled`. + -> **NOTE:** Geo Redundant Backups cannot be configured when using the `Basic` tier. ## Attributes Reference