provider/azurerm: Support AzureRM Sql Database DataWarehouse
Fixes #9194 Removes the validation for the types and adds an acceptance test to make sure we get a successful Sql Database created ``` % make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMSqlDatabase_datawarehouse' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2016/10/03 21:57:16 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMSqlDatabase_datawarehouse -timeout 120m === RUN TestAccAzureRMSqlDatabase_datawarehouse --- PASS: TestAccAzureRMSqlDatabase_datawarehouse (307.95s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm307.963s ```
This commit is contained in:
parent
a879323d23
commit
9089b415d4
|
@ -17,103 +17,103 @@ func resourceArmSqlDatabase() *schema.Resource {
|
|||
Delete: resourceArmSqlDatabaseDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"location": &schema.Schema{
|
||||
"location": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
StateFunc: azureRMNormalizeLocation,
|
||||
},
|
||||
|
||||
"resource_group_name": &schema.Schema{
|
||||
"resource_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"server_name": &schema.Schema{
|
||||
"server_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"create_mode": &schema.Schema{
|
||||
"create_mode": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "Default",
|
||||
},
|
||||
|
||||
"source_database_id": &schema.Schema{
|
||||
"source_database_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"restore_point_in_time": &schema.Schema{
|
||||
"restore_point_in_time": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"edition": &schema.Schema{
|
||||
"edition": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validateArmSqlDatabaseEdition,
|
||||
},
|
||||
|
||||
"collation": &schema.Schema{
|
||||
"collation": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"max_size_bytes": &schema.Schema{
|
||||
"max_size_bytes": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"requested_service_objective_id": &schema.Schema{
|
||||
"requested_service_objective_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"requested_service_objective_name": &schema.Schema{
|
||||
"requested_service_objective_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"source_database_deletion_date": &schema.Schema{
|
||||
"source_database_deletion_date": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"elastic_pool_name": &schema.Schema{
|
||||
"elastic_pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"encryption": &schema.Schema{
|
||||
"encryption": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"creation_date": &schema.Schema{
|
||||
"creation_date": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"default_secondary_location": &schema.Schema{
|
||||
"default_secondary_location": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
@ -248,10 +248,10 @@ func validateArmSqlDatabaseEdition(v interface{}, k string) (ws []string, errors
|
|||
"Basic": true,
|
||||
"Standard": true,
|
||||
"Premium": true,
|
||||
"DataWarehouse": true,
|
||||
}
|
||||
|
||||
if !editions[v.(string)] {
|
||||
errors = append(errors, fmt.Errorf("SQL Database Edition can only be Basic, Standard or Premium"))
|
||||
errors = append(errors, fmt.Errorf("SQL Database Edition can only be Basic, Standard, Premium or DataWarehouse"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@ func TestResourceAzureRMSqlDatabaseEdition_validation(t *testing.T) {
|
|||
Value: "Premium",
|
||||
ErrCount: 0,
|
||||
},
|
||||
{
|
||||
Value: "DataWarehouse",
|
||||
ErrCount: 0,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
@ -51,7 +55,7 @@ func TestAccAzureRMSqlDatabase_basic(t *testing.T) {
|
|||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMSqlDatabaseDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMSqlDatabaseExists("azurerm_sql_database.test"),
|
||||
|
@ -71,7 +75,7 @@ func TestAccAzureRMSqlDatabase_withTags(t *testing.T) {
|
|||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMSqlDatabaseDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: preConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMSqlDatabaseExists("azurerm_sql_database.test"),
|
||||
|
@ -79,8 +83,7 @@ func TestAccAzureRMSqlDatabase_withTags(t *testing.T) {
|
|||
"azurerm_sql_database.test", "tags.%", "2"),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: postConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMSqlDatabaseExists("azurerm_sql_database.test"),
|
||||
|
@ -92,6 +95,25 @@ func TestAccAzureRMSqlDatabase_withTags(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAzureRMSqlDatabase_datawarehouse(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
config := fmt.Sprintf(testAccAzureRMSqlDatabase_datawarehouse, 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"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testCheckAzureRMSqlDatabaseExists(name string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
|
||||
|
@ -227,3 +249,28 @@ resource "azurerm_sql_database" "test" {
|
|||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMSqlDatabase_datawarehouse = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctest_rg_%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 = "DataWarehouse"
|
||||
collation = "SQL_Latin1_General_CP1_CI_AS"
|
||||
requested_service_objective_name = "DW400"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -46,7 +46,7 @@ The following arguments are supported:
|
|||
|
||||
* `restore_point_in_time` - (Optional) The point in time for the restore. Only applies if `create_mode` is `PointInTimeRestore` e.g. 2013-11-08T22:00:40Z
|
||||
|
||||
* `edition` - (Optional) The edition of the database to be created. Applies only if `create_mode` is `Default`. Valid values are: `Basic`, `Standard`, `Premium`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
|
||||
* `edition` - (Optional) The edition of the database to be created. Applies only if `create_mode` is `Default`. Valid values are: `Basic`, `Standard`, `Premium`, or `DataWarehouse`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
|
||||
|
||||
* `collation` - (Optional) The name of the collation. Applies only if `create_mode` is `Default`. Azure default is `SQL_LATIN1_GENERAL_CP1_CI_AS`
|
||||
|
||||
|
|
Loading…
Reference in New Issue