hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.59k stars 4.63k forks source link

azurerm_sql_elasticpool Example Usage code fails #93

Closed hashibot closed 7 years ago

hashibot commented 7 years ago

This issue was originally opened by @holmesb as hashicorp/terraform#14785. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

v0.9.5

Affected Resource(s)

azurerm_sql_elasticpool

Terraform Configuration Files

Example Usage code:

  name = "test"
  location = "West US"
}

resource "azurerm_sql_server" "test" {
    name = "test"
    resource_group_name = "${azurerm_resource_group.test.name}"
    location = "West US"
    version = "12.0"
    administrator_login = "4dm1n157r470r"
    administrator_login_password = "4-v3ry-53cr37-p455w0rd"
}

resource "azurerm_sql_elasticpool" "test" {
    name = "test"
    resource_group_name = "${azurerm_resource_group.test.name}"
    location = "West US"
    server_name = "${azurerm_sql_server.test.name}"
    edition = "Basic"
    dtu = 100
    db_min_dtu = 0
    db_max_dtu = 5
    pool_size = 5000
}

Expected Behavior

SQL Elastic pool is created

Actual Behavior

Running Example Usage code gives: "invalid or unknown key: db_max_dtu" "invalid or unknown key: db_min_dtu"

After removing these two attributes, get

Error applying plan:

1 error(s) occurred:

* azurerm_sql_server.test: 1 error(s) occurred:

* azurerm_sql_server.test: Error creating SQL Server: PUT https://management.azure.com/subscriptions/4689b617-acad-40dc-a40f-77a442339589/resourceGroups/test_resource_group/providers/Microsoft.Sql/servers/test?api-version=2014-04-01-preview giving up after 5 attempts

Terraform does not automatically rollback in the face of errors...

And then on second attempt:

Error applying plan:

1 error(s) occurred:

* azurerm_sql_server.test: 1 error(s) occurred:

* azurerm_sql_server.test: Error creating SQL Server: 40647 (404) - Subscription '4689b617-acad-40dc-a40f-77a442339589' does not have the server 'test'.

Terraform does not automatically rollback in the face of errors..

Steps to Reproduce

Run Example Usage code

dominik-lekse commented 7 years ago

@holmesb @tombuildsstuff There are three different issues here which make the situation a bit more complicated.

  1. The example usage in the issue does not match the documenation. The example in the documentation contain the correct key names db_min_dtu and db_max_dtu.
  2. When running the example usage, the azurerm_sql_server resource fails since its name test is not unique across the entire Azure environment. This is similar to the name of storage accounts. However, the resulting error is misleading which is a different issue and it is currently not documented in the azurerm_sql_server resource documentation.
  3. In the example usage of the azurerm_sql_elasticpool documentation, the dtu value does not match the pool_size. This needs to be fixed in the documentation of azurerm_sql_elasticpool.
resource "azurerm_sql_elasticpool" "test" {
    name = "test"
    resource_group_name = "${azurerm_resource_group.test.name}"
    location = "West US"
    server_name = "${azurerm_sql_server.test.name}"
    edition = "Basic"
    dtu = 50
    db_dtu_min = 0
    db_dtu_max = 5
    pool_size = 5000
}
tombuildsstuff commented 7 years ago

@dominik-lekse apologies for the delayed response to this

  1. The example usage in the issue does not match the documenation. The example in the documentation contain the correct key names db_min_dtu and db_max_dtu.

I think this comes from an earlier incorrect version of the documentation page

  1. When running the example usage, the azurerm_sql_server resource fails since its name test is not unique across the entire Azure environment. This is similar to the name of storage accounts. However, the resulting error is misleading which is a different issue and it is currently not documented in the azurerm_sql_server resource documentation.

I've updated the documentation to state this needs to be globally unique in #289 - and the examples with a comment to this effect. In addition - I've now updated the code to return a friendlier error if the name is in use - and I'm just working through testing this at the moment.

  1. In the example usage of the azurerm_sql_elasticpool documentation, the dtu value does not match the pool_size. This needs to be fixed in the documentation of azurerm_sql_elasticpool.

I've updated this in the documentation in #289. As such I believe we should be able to close this issue once #289 is merged.

Thanks!

srusru commented 6 years ago

Hi @tombuildsstuff i am able to create the azurerm_sql_elasticpool with the basic tier edition. but when i add it as premium tier in the terraform scripts, it throws error. my script is resource "azurerm_sql_elasticpool" "elasticpool" { name = "prod-epool" resource_group_name = "${azurerm_resource_group.rg.name}" location = "${azurerm_resource_group.rg.location}" server_name = "${azurerm_sql_server.sql_server.name}" edition = "Premium" dtu = 2000 db_dtu_min = 0 db_dtu_max = 1750 pool_size = 5000 }

The error i get when i execute the terraform script is

Any help is appriciated. Thanks

tombuildsstuff commented 6 years ago

@reddyed can you please open a new issue specifically for this? Thanks!