Skip to content

Commit

Permalink
add zone_redundant as editable flag for mssql_elasticpool
Browse files Browse the repository at this point in the history
  • Loading branch information
bs-matil committed Mar 22, 2019
1 parent a51fddf commit 46b705e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
5 changes: 4 additions & 1 deletion azurerm/resource_arm_mssql_elasticpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ func resourceArmMsSqlElasticPool() *schema.Resource {

"zone_redundant": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
Default: false,
},

"tags": tagsSchema(),
Expand All @@ -202,6 +203,7 @@ func resourceArmMsSqlElasticPoolCreateUpdate(d *schema.ResourceData, meta interf
elasticPoolName := d.Get("name").(string)
serverName := d.Get("server_name").(string)
resGroup := d.Get("resource_group_name").(string)
zoneredundant := d.Get("zone_redundant").(bool)

if requireResourcesToBeImported && d.IsNewResource() {
existing, err := client.Get(ctx, resGroup, serverName, elasticPoolName)
Expand All @@ -227,6 +229,7 @@ func resourceArmMsSqlElasticPoolCreateUpdate(d *schema.ResourceData, meta interf
Tags: expandTags(tags),
ElasticPoolProperties: &sql.ElasticPoolProperties{
PerDatabaseSettings: expandAzureRmMsSqlElasticPoolPerDatabaseSettings(d),
ZoneRedundant: &zoneredundant,
},
}

Expand Down
49 changes: 41 additions & 8 deletions azurerm/resource_arm_mssql_elasticpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,34 @@ func TestAccAzureRMMsSqlElasticPool_standard_DTU(t *testing.T) {
})
}

func TestAccAzureRMMsSqlElasticPool_premium_DTU_zone_redundant(t *testing.T) {
resourceName := "azurerm_mssql_elasticpool.test"
ri := tf.AccRandTimeInt()
config := testAccAzureRMMsSqlElasticPool_premium_DTU_zone_redundant(ri, testLocation())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMMsSqlElasticPoolDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMsSqlElasticPoolExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "PremiumPool"),
resource.TestCheckResourceAttr(resourceName, "zone_redundant", "true"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_size_gb"},
},
},
})
}

func TestAccAzureRMMsSqlElasticPool_basic_vCore(t *testing.T) {
resourceName := "azurerm_mssql_elasticpool.test"
ri := tf.AccRandTimeInt()
Expand Down Expand Up @@ -337,15 +365,15 @@ func testCheckAzureRMMsSqlElasticPoolDisappears(resourceName string) resource.Te
}

func testAccAzureRMMsSqlElasticPool_basic_DTU(rInt int, location string) string {
return testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "BasicPool", "Basic", 50, 4.8828125, 0, 5)
return testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "BasicPool", "Basic", 50, 4.8828125, 0, 5, false)
}

func testAccAzureRMMsSqlElasticPool_requiresImport(rInt int, location string) string {
template := testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "BasicPool", "Basic", 50, 5242880000, 0, 5)
template := testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "BasicPool", "Basic", 50, 5242880000, 0, 5, false)
return fmt.Sprintf(`
%s
resource "azurerm_mssql_elasticpool" "test" {
resource "azurerm_mssql_elasticpool" "import" {
name = "${azurerm_mssql_elasticpool.test.name}"
resource_group_name = "${azurerm_mssql_elasticpool.test.resource_group_name}"
location = "${azurerm_mssql_elasticpool.test.location}"
Expand All @@ -357,12 +385,16 @@ resource "azurerm_mssql_elasticpool" "test" {
`, template)
}

func testAccAzureRMMsSqlElasticPool_premium_DTU_zone_redundant(rInt int, location string) string {
return testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "PremiumPool", "Premium", 125, 50, 0, 50, true)
}

func testAccAzureRMMsSqlElasticPool_standard_DTU(rInt int, location string) string {
return testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "StandardPool", "Standard", 50, 50, 0, 50)
return testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "StandardPool", "Standard", 50, 50, 0, 50, false)
}

func testAccAzureRMMsSqlElasticPool_resize_DTU(rInt int, location string) string {
return testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "StandardPool", "Standard", 100, 100, 50, 100)
return testAccAzureRMMsSqlElasticPool_DTU_Template(rInt, location, "StandardPool", "Standard", 100, 100, 50, 100, false)
}

func testAccAzureRMMsSqlElasticPool_basic_vCore(rInt int, location string) string {
Expand Down Expand Up @@ -453,7 +485,7 @@ resource "azurerm_mssql_elasticpool" "test" {
`, rInt, location, skuName, skuTier, skuCapacity, skuFamily, databaseSettingsMin, databaseSettingsMax)
}

func testAccAzureRMMsSqlElasticPool_DTU_Template(rInt int, location string, skuName string, skuTier string, skuCapacity int, maxSizeGB float64, databaseSettingsMin int, databaseSettingsMax int) string {
func testAccAzureRMMsSqlElasticPool_DTU_Template(rInt int, location string, skuName string, skuTier string, skuCapacity int, maxSizeGB float64, databaseSettingsMin int, databaseSettingsMax int, zoneRedundant bool) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%[1]d"
Expand All @@ -474,7 +506,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_gb = %.7[6]f
max_size_gb = %.7[6]f
zone_redundant = %[9]t
sku {
name = "%[3]s"
Expand All @@ -487,5 +520,5 @@ resource "azurerm_mssql_elasticpool" "test" {
max_capacity = %[8]d
}
}
`, rInt, location, skuName, skuTier, skuCapacity, maxSizeGB, databaseSettingsMin, databaseSettingsMax)
`, rInt, location, skuName, skuTier, skuCapacity, maxSizeGB, databaseSettingsMin, databaseSettingsMax, zoneRedundant)
}
4 changes: 2 additions & 2 deletions website/docs/r/mssql_elasticpool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ The following arguments are supported:

---

* `zone_redundant` - (Optional) Whether or not this elastic pool is zone redundant. `tier` needs to be `Premium` for `DTU` based or `BusinessCritical` for `vCore` based `sku`. Defaults to `false`.

## Attributes Reference

The following attributes are exported:

* `id` - The MsSQL Elastic Pool ID.

* `zone_redundant` - Whether or not this elastic pool is zone redundant.

## Import

SQL Elastic Pool can be imported using the `resource id`, e.g.
Expand Down

0 comments on commit 46b705e

Please sign in to comment.