diff --git a/azurerm/resource_arm_postgresql_server.go b/azurerm/resource_arm_postgresql_server.go index f3ac12bed6a6..bd70a5a72966 100644 --- a/azurerm/resource_arm_postgresql_server.go +++ b/azurerm/resource_arm_postgresql_server.go @@ -166,6 +166,16 @@ func resourceArmPostgreSQLServer() *schema.Resource { }, true), DiffSuppressFunc: suppress.CaseDifference, }, + "auto_grow": { + Type: schema.TypeString, + Optional: true, + Default: string(postgresql.StorageAutogrowEnabled), + ValidateFunc: validation.StringInSlice([]string{ + string(postgresql.StorageAutogrowEnabled), + string(postgresql.StorageAutogrowDisabled), + }, true), + DiffSuppressFunc: suppress.CaseDifference, + }, }, }, }, @@ -424,11 +434,13 @@ func expandAzureRmPostgreSQLStorageProfile(d *schema.ResourceData) *postgresql.S backupRetentionDays := storageprofile["backup_retention_days"].(int) geoRedundantBackup := storageprofile["geo_redundant_backup"].(string) storageMB := storageprofile["storage_mb"].(int) + autoGrow := storageprofile["auto_grow"].(string) return &postgresql.StorageProfile{ BackupRetentionDays: utils.Int32(int32(backupRetentionDays)), GeoRedundantBackup: postgresql.GeoRedundantBackup(geoRedundantBackup), StorageMB: utils.Int32(int32(storageMB)), + StorageAutogrow: postgresql.StorageAutogrow(autoGrow), } } @@ -459,6 +471,8 @@ func flattenPostgreSQLStorageProfile(resp *postgresql.StorageProfile) []interfac values["storage_mb"] = *storageMB } + values["auto_grow"] = string(resp.StorageAutogrow) + if backupRetentionDays := resp.BackupRetentionDays; backupRetentionDays != nil { values["backup_retention_days"] = *backupRetentionDays } diff --git a/azurerm/resource_arm_postgresql_server_test.go b/azurerm/resource_arm_postgresql_server_test.go index f6d3c385efc4..975390457b44 100644 --- a/azurerm/resource_arm_postgresql_server_test.go +++ b/azurerm/resource_arm_postgresql_server_test.go @@ -298,6 +298,7 @@ func TestAccAzureRMPostgreSQLServer_updated(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "sku.0.name", "GP_Gen5_2"), resource.TestCheckResourceAttr(resourceName, "version", "9.6"), resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "51200"), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.auto_grow", "Disabled"), resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), ), }, @@ -308,6 +309,7 @@ func TestAccAzureRMPostgreSQLServer_updated(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "sku.0.name", "GP_Gen5_4"), resource.TestCheckResourceAttr(resourceName, "version", "9.6"), resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "640000"), + resource.TestCheckResourceAttr(resourceName, "storage_profile.0.auto_grow", "Enabled"), resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), ), }, @@ -438,6 +440,7 @@ resource "azurerm_postgresql_server" "test" { storage_mb = 51200 backup_retention_days = 7 geo_redundant_backup = "Disabled" + auto_grow = "Disabled" } administrator_login = "acctestun" @@ -583,6 +586,7 @@ resource "azurerm_postgresql_server" "test" { storage_mb = 947200 backup_retention_days = 7 geo_redundant_backup = "Disabled" + auto_grow = "Enabled" } administrator_login = "acctestun" diff --git a/website/docs/r/postgresql_server.html.markdown b/website/docs/r/postgresql_server.html.markdown index 34318962e5f6..5a3e6460724b 100644 --- a/website/docs/r/postgresql_server.html.markdown +++ b/website/docs/r/postgresql_server.html.markdown @@ -34,6 +34,7 @@ resource "azurerm_postgresql_server" "test" { storage_mb = 5120 backup_retention_days = 7 geo_redundant_backup = "Disabled" + auto_grow = "Enabled" } administrator_login = "psqladminun" @@ -89,6 +90,8 @@ The following arguments are supported: * `geo_redundant_backup` - (Optional) Enable/Disable Geo-redundant for server backup. Valid values for this property are `Enabled` or `Disabled`, not supported for the `basic` tier. This allows you to choose between locally redundant or geo-redundant backup storage in the General Purpose and Memory Optimized tiers. When the backups are stored in geo-redundant backup storage, they are not only stored within the region in which your server is hosted, but are also replicated to a paired data center. This provides better protection and ability to restore your server in a different region in the event of a disaster. The Basic tier only offers locally redundant backup storage. +* `auto_grow` - (Optional) Enable/Disable auto-growing of the storage. Valid values for this property are `Enabled` or `Disabled`. Storage auto-grow prevents your server from running out of storage and becoming read-only. If storage auto grow is enabled, the storage automatically grows without impacting the workload. The default value if not explicitly specified is `Enabled`. + ## Attributes Reference The following attributes are exported: