Skip to content

Commit

Permalink
Merge pull request #4302 from r0bnet/mariadb-storage-autogrow
Browse files Browse the repository at this point in the history
Mariadb storage autogrow
  • Loading branch information
tombuildsstuff committed Sep 12, 2019
2 parents c6fe70b + e95fa06 commit b7975eb
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
14 changes: 14 additions & 0 deletions azurerm/resource_arm_mariadb_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
},
},
Expand Down Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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}
}
64 changes: 63 additions & 1 deletion azurerm/resource_arm_mariadb_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
3 changes: 3 additions & 0 deletions website/docs/r/mariadb_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b7975eb

Please sign in to comment.