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

Including set max_size_bytes #2346

Merged
merged 11 commits into from
Jan 12, 2019
14 changes: 12 additions & 2 deletions azurerm/resource_arm_mssql_elasticpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ func resourceArmMsSqlElasticPool() *schema.Resource {
},

"tags": tagsSchema(),

"max_size_bytes": {
katbyte marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(0),
},
},

CustomizeDiff: func(diff *schema.ResourceDiff, v interface{}) error {
Expand Down Expand Up @@ -313,7 +319,7 @@ func resourceArmMsSqlElasticPoolRead(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error setting `sku`: %+v", err)
}

if err := d.Set("elastic_pool_properties", flattenAzureRmMsSqlElasticPoolProperties(resp.ElasticPoolProperties)); err != nil {
if err := d.Set("elastic_pool_properties", flattenAzureRmMsSqlElasticPoolProperties(d, resp.ElasticPoolProperties)); err != nil {
return fmt.Errorf("Error setting `elastic_pool_properties`: %+v", err)
}

Expand Down Expand Up @@ -355,11 +361,14 @@ func expandAzureRmMsSqlElasticPoolProperties(d *schema.ResourceData) *sql.Elasti
minCapacity := perDatabaseSetting["min_capacity"].(float64)
maxCapacity := perDatabaseSetting["max_capacity"].(float64)

maxSizeBytes := int64(d.Get("max_size_bytes").(int))

return &sql.ElasticPoolProperties{
PerDatabaseSettings: &sql.ElasticPoolPerDatabaseSettings{
MinCapacity: utils.Float(minCapacity),
MaxCapacity: utils.Float(maxCapacity),
},
MaxSizeBytes: utils.Int64(maxSizeBytes),
}
}

Expand Down Expand Up @@ -402,11 +411,12 @@ func flattenAzureRmMsSqlElasticPoolSku(resp *sql.Sku) []interface{} {
return []interface{}{values}
}

func flattenAzureRmMsSqlElasticPoolProperties(resp *sql.ElasticPoolProperties) []interface{} {
func flattenAzureRmMsSqlElasticPoolProperties(d *schema.ResourceData, resp *sql.ElasticPoolProperties) []interface{} {
elasticPoolProperty := map[string]interface{}{}

if maxSizeBytes := resp.MaxSizeBytes; maxSizeBytes != nil {
elasticPoolProperty["max_size_bytes"] = *maxSizeBytes
d.Set("max_size_bytes", *maxSizeBytes)
}

elasticPoolProperty["state"] = string(resp.State)
Expand Down
4 changes: 3 additions & 1 deletion azurerm/resource_arm_mssql_elasticpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ resource "azurerm_mssql_elasticpool" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
server_name = "${azurerm_sql_server.test.name}"
max_size_bytes = 5368709120

sku {
name = "%[3]s"
Expand Down Expand Up @@ -326,7 +327,8 @@ resource "azurerm_mssql_elasticpool" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
server_name = "${azurerm_sql_server.test.name}"

max_size_bytes = 5368709120

sku {
name = "%[3]s"
tier = "%[4]s"
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/mssql_elasticpool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "azurerm_mssql_elasticpool" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
server_name = "${azurerm_sql_server.test.name}"
max_size_bytes = 5368709120

sku {
name = "GP_Gen5"
Expand Down Expand Up @@ -63,6 +64,8 @@ The following arguments are supported:

* `per_database_settings` - (Required) A `per_database_settings` block as defined below.

* `max_size_bytes` - (Required) The max data size of the elastic pool.
katbyte marked this conversation as resolved.
Show resolved Hide resolved

* `tags` - (Optional) A mapping of tags to assign to the resource.

---
Expand Down