Skip to content

Commit

Permalink
Merge pull request #1449 from gabinante/bugfix/database-size-update
Browse files Browse the repository at this point in the history
update azurerm_postgresql_server/azurerm_mysql_server storage_mb validation bounds
  • Loading branch information
katbyte authored Jun 28, 2018
2 parents e471648 + 47fa45a commit d3cdd17
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
15 changes: 14 additions & 1 deletion azurerm/resource_arm_mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package azurerm
import (
"fmt"
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-12-01/mysql"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -135,7 +136,7 @@ func resourceArmMySqlServer() *schema.Resource {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validateIntBetweenDivisibleBy(5120, 1048576, 1024),
ValidateFunc: validateIntBetweenDivisibleBy(5120, 4194304, 1024),
},
"backup_retention_days": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -172,6 +173,18 @@ func resourceArmMySqlServer() *schema.Resource {

"tags": tagsSchema(),
},

CustomizeDiff: func(diff *schema.ResourceDiff, v interface{}) error {

tier, _ := diff.GetOk("sku.0.tier")
storageMB, _ := diff.GetOk("storage_profile.0.storage_mb")

if strings.ToLower(tier.(string)) == "basic" && storageMB.(int) > 1048576 {
return fmt.Errorf("basic pricing tier only supports upto 1,048,576 MB (1TB) of storage")
}

return nil
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_mysql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ resource "azurerm_mysql_server" "test" {
}
storage_profile {
storage_mb = 1048576,
storage_mb = 4194304,
backup_retention_days = 7
geo_redundant_backup = "Enabled"
}
Expand Down
15 changes: 14 additions & 1 deletion azurerm/resource_arm_postgresql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package azurerm
import (
"fmt"
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -136,7 +137,7 @@ func resourceArmPostgreSQLServer() *schema.Resource {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validateIntBetweenDivisibleBy(5120, 1048576, 1024),
ValidateFunc: validateIntBetweenDivisibleBy(5120, 4194304, 1024),
},

"backup_retention_days": {
Expand Down Expand Up @@ -175,6 +176,18 @@ func resourceArmPostgreSQLServer() *schema.Resource {

"tags": tagsSchema(),
},

CustomizeDiff: func(diff *schema.ResourceDiff, v interface{}) error {

tier, _ := diff.GetOk("sku.0.tier")
storageMB, _ := diff.GetOk("storage_profile.0.storage_mb")

if strings.ToLower(tier.(string)) == "basic" && storageMB.(int) > 1048576 {
return fmt.Errorf("basic pricing tier only supports upto 1,048,576 MB (1TB) of storage")
}

return nil
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_postgresql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ resource "azurerm_postgresql_server" "test" {
}
storage_profile {
storage_mb = 1048576
storage_mb = 4194304
backup_retention_days = 7
geo_redundant_backup = "Enabled"
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/mysql_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The following arguments are supported:

`storage_profile` supports the following:

* `storage_mb` - (Required) Max storage allowed for a server, possible values are between `5120 MB` (5GB) and `1048576 MB` (1TB). The step for this value must be in `1024 MB` (1GB) increments. For more information see the [product documentation](https://docs.microsoft.com/en-us/rest/api/mysql/servers/create#StorageProfile).
* `storage_mb` - (Required) Max storage allowed for a server. Possible values are between `5120` MB(5GB) and `1048576` MB(1TB) for the Basic SKU and between `5120` MB(5GB) and `4194304` MB(4TB) for General Purpose/Memory Optimized SKUs. For more information see the [product documentation](https://docs.microsoft.com/en-us/rest/api/mysql/servers/create#StorageProfile).

* `backup_retention_days` - (Optional) Backup retention days for the server, supported values are between `7` and `35` days.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/postgresql_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The following arguments are supported:

`storage_profile` supports the following:

* `storage_mb` - (Required) Max storage allowed for a server, possible values are between `5120 MB` (5GB) and `1048576 MB` (1TB). The step for this value must be in `1024 MB` (1GB) increments. For more information see the [product documentation](https://docs.microsoft.com/en-us/rest/api/postgresql/servers/create#StorageProfile).
* `storage_mb` - (Required) Max storage allowed for a server. Possible values are between `5120` MB(5GB) and `1048576` MB(1TB) for the Basic SKU and between `5120` MB(5GB) and `4194304` MB(4TB) for General Purpose/Memory Optimized SKUs. For more information see the [product documentation](https://docs.microsoft.com/en-us/rest/api/postgresql/servers/create#StorageProfile).

* `backup_retention_days` - (Optional) Backup retention days for the server, supported values are between `7` and `35` days.

Expand Down

0 comments on commit d3cdd17

Please sign in to comment.