diff --git a/builtin/providers/azurerm/resource_arm_sql_database.go b/builtin/providers/azurerm/resource_arm_sql_database.go index b022c7d1b..6959586b5 100644 --- a/builtin/providers/azurerm/resource_arm_sql_database.go +++ b/builtin/providers/azurerm/resource_arm_sql_database.go @@ -158,6 +158,10 @@ func resourceArmSqlDatabaseCreate(d *schema.ResourceData, meta interface{}) erro command.RequestedServiceObjectiveID = azure.String(v.(string)) } + if v, ok := d.GetOk("elastic_pool_name"); ok { + command.ElasticPoolName = azure.String(v.(string)) + } + if v, ok := d.GetOk("requested_service_objective_name"); ok { command.RequestedServiceObjectiveName = azure.String(v.(string)) } @@ -216,6 +220,7 @@ func resourceArmSqlDatabaseRead(d *schema.ResourceData, meta interface{}) error d.Set("name", resp.Name) d.Set("creation_date", resp.CreationDate) d.Set("default_secondary_location", resp.DefaultSecondaryLocation) + d.Set("elastic_pool_name", resp.ElasticPoolName) flattenAndSetTags(d, resp.Tags) diff --git a/builtin/providers/azurerm/resource_arm_sql_database_test.go b/builtin/providers/azurerm/resource_arm_sql_database_test.go index 9f80eb426..b9e2d601c 100644 --- a/builtin/providers/azurerm/resource_arm_sql_database_test.go +++ b/builtin/providers/azurerm/resource_arm_sql_database_test.go @@ -65,6 +65,26 @@ func TestAccAzureRMSqlDatabase_basic(t *testing.T) { }) } +func TestAccAzureRMSqlDatabase_elasticPool(t *testing.T) { + ri := acctest.RandInt() + config := fmt.Sprintf(testAccAzureRMSqlDatabase_elasticPool, ri, ri, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMSqlDatabaseDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMSqlDatabaseExists("azurerm_sql_database.test"), + resource.TestCheckResourceAttr("azurerm_sql_database.test", "elastic_pool_name", "test_ep"), + ), + }, + }, + }) +} + func TestAccAzureRMSqlDatabase_withTags(t *testing.T) { ri := acctest.RandInt() preConfig := fmt.Sprintf(testAccAzureRMSqlDatabase_withTags, ri, ri, ri) @@ -163,6 +183,33 @@ func testCheckAzureRMSqlDatabaseDestroy(s *terraform.State) error { return nil } +var testAccAzureRMSqlDatabase_elasticPool = ` +resource "azurerm_resource_group" "test" { + name = "acctestRG_%d" + location = "West US" +} +resource "azurerm_sql_server" "test" { + name = "acctestsqlserver%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "West US" + version = "12.0" + administrator_login = "mradministrator" + administrator_login_password = "thisIsDog11" +} + +resource "azurerm_sql_database" "test" { + name = "acctestdb%d" + resource_group_name = "${azurerm_resource_group.test.name}" + server_name = "${azurerm_sql_server.test.name}" + location = "West US" + edition = "Standard" + collation = "SQL_Latin1_General_CP1_CI_AS" + max_size_bytes = "1073741824" + elastic_pool_name = "test_ep" + requested_service_objective_name = "ElasticPool" +} +` + var testAccAzureRMSqlDatabase_basic = ` resource "azurerm_resource_group" "test" { name = "acctestRG_%d"