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

Changing azurerm_mssql_database sku_name deletes and recreates database instead of scaling #7461

Closed
samcook opened this issue Jun 24, 2020 · 3 comments · Fixed by #7559
Closed
Labels
bug service/mssql Microsoft SQL Server

Comments

@samcook
Copy link
Contributor

samcook commented Jun 24, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.12.26
+ provider.azurerm v2.15.0

Affected Resource(s)

  • azurerm_mssql_database

Terraform Configuration Files

terraform {
  required_version = ">= 0.12.0"
}

provider "azurerm" {
  version = "~>2.0"
  features {}
}

data "azurerm_sql_server" "sql_server" {
  name                = "test-sql"
  resource_group_name = "test-rg"
}

resource "azurerm_mssql_database" "db" {
  name        = "test-db"
  server_id   = data.azurerm_sql_server.sql_server.id
  sku_name    = "S0"
  max_size_gb = 2
  read_scale  = false
  collation   = "SQL_LATIN1_GENERAL_CP1_CI_AS"
  create_mode = "Default"
}

Debug Output

Panic Output

Expected Behavior

Terraform updates the database scale when changing the sku_name without deleting and recreating the database (where allowed, I'm aware some types of sku changes aren't permitted)

Actual Behavior

Terraform deletes and recreates the database.

Terraform will perform the following actions:

  # azurerm_mssql_database.db must be replaced
-/+ resource "azurerm_mssql_database" "db" {
      ~ auto_pause_delay_in_minutes = 0 -> (known after apply)
        collation                   = "SQL_LATIN1_GENERAL_CP1_CI_AS"
        create_mode                 = "Default"
      + creation_source_database_id = (known after apply)
      ~ id                          = "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Sql/servers/test-sql/databases/test-db" -> (known after apply)
      + license_type                = (known after apply)
        max_size_gb                 = 2
      ~ min_capacity                = 0 -> (known after apply)
        name                        = "test-db"
      ~ read_replica_count          = 0 -> (known after apply)
        read_scale                  = false
      + restore_point_in_time       = (known after apply)
      + sample_name                 = (known after apply)
        server_id                   = "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Sql/servers/test-sql"
      ~ sku_name                    = "S0" -> "S1" # forces replacement
      - tags                        = {} -> null
      ~ zone_redundant              = false -> (known after apply)

      ~ threat_detection_policy {
          ~ disabled_alerts            = [] -> (known after apply)
          ~ email_account_admins       = "Disabled" -> (known after apply)
          ~ email_addresses            = [] -> (known after apply)
          ~ retention_days             = 0 -> (known after apply)
          ~ state                      = "Disabled" -> (known after apply)
          + storage_account_access_key = (sensitive value)
          + storage_endpoint           = (known after apply)
          ~ use_server_default         = "Disabled" -> (known after apply)
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes
azurerm_mssql_database.db: Destroying... [id=/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Sql/servers/test-sql/databases/test-db]
azurerm_mssql_database.db: Still destroying... [id=/subscriptions/xxxx...test-sql/databases/test-db, 10s elapsed]
azurerm_mssql_database.db: Destruction complete after 18s
azurerm_mssql_database.db: Creating...
azurerm_mssql_database.db: Still creating... [10s elapsed]
azurerm_mssql_database.db: Still creating... [20s elapsed]
azurerm_mssql_database.db: Still creating... [30s elapsed]
azurerm_mssql_database.db: Still creating... [40s elapsed]
azurerm_mssql_database.db: Still creating... [50s elapsed]
azurerm_mssql_database.db: Still creating... [1m0s elapsed]
azurerm_mssql_database.db: Creation complete after 1m1s [id=/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Sql/servers/test-sql/databases/test-db]

Apply complete! Resources: 1 added, 0 changed, 1 destroyed.

Steps to Reproduce

  1. terraform apply to initially to create the database.
  2. Modify the sku_name to change the database scale (e.g. S0 -> S1).
  3. terraform apply again.

Important Factoids

References

@mybayern1974 mybayern1974 added the service/mssql Microsoft SQL Server label Jun 24, 2020
@yupwei68
Copy link
Contributor

Hi @samcook ,thanks for opening this issue. It just the HS can't be switched to other sku_tier. I'll fix this and do a customDiff for the sku_name soon.

@ghost
Copy link

ghost commented Aug 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug service/mssql Microsoft SQL Server
Projects
None yet
4 participants