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

Mariadb storage autogrow #4302

Merged
merged 4 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 13 additions & 0 deletions azurerm/resource_arm_mariadb_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ func resourceArmMariaDbServer() *schema.Resource {
string(mariadb.Disabled),
}, false),
},

"storage_autogrow": {
r0bnet marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
r0bnet marked this conversation as resolved.
Show resolved Hide resolved
string(mariadb.StorageAutogrowEnabled),
string(mariadb.StorageAutogrowDisabled),
}, false),
},
},
},
},
Expand Down Expand Up @@ -400,11 +409,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["storage_autogrow"].(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 +460,7 @@ func flattenMariaDbStorageProfile(storage *mariadb.StorageProfile) []interface{}

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

values["storage_autogrow"] = string(storage.StorageAutogrow)

return []interface{}{values}
}
65 changes: 64 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.storage_autogrow", "Disabled"),
),
},
{
Config: updatedConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMariaDbServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_autogrow", "Enabled"),
),
},
},
})
}

func testCheckAzureRMMariaDbServerExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
Expand Down Expand Up @@ -344,6 +372,7 @@ resource "azurerm_mariadb_server" "test" {
storage_mb = 51200
backup_retention_days = 7
geo_redundant_backup = "Disabled"
storage_autogrow = "Disabled"
r0bnet marked this conversation as resolved.
Show resolved Hide resolved
}

administrator_login = "acctestun"
Expand Down Expand Up @@ -582,3 +611,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"
storage_autogrow = "Enabled"
}

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`.

* `storage_autogrow` - (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