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

add zone_redundant as editable flag for mssql_elasticpool #3104

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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,
bs-matil marked this conversation as resolved.
Show resolved Hide resolved
},

"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,
bs-matil marked this conversation as resolved.
Show resolved Hide resolved
},
}

Expand Down
47 changes: 40 additions & 7 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,11 +365,11 @@ 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

Expand All @@ -357,12 +385,16 @@ resource "azurerm_mssql_elasticpool" "import" {
`, 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
bs-matil marked this conversation as resolved.
Show resolved Hide resolved
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`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katbyte should we leave the Defaults to false here? As its the API behavior anyways its still may a fair hint?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave it as yes that is what the api does by default.


## 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