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.48k stars 4.57k forks source link

Error: serverless databases do not support license type #23103

Open leandromsft opened 11 months ago

leandromsft commented 11 months ago

Is there an existing issue for this?

Community Note

I'm trying to apply a SQL Server database change from Provisioned to Serverless configuring the field sku_name from GP_Gen5_2 to GP_S_Gen5_2 and I get the error below.

 Error: serverless databases do not support license type
│
│   with module.sql_server.azurerm_mssql_database.sqldb,
│   on modules\sql-server\main.tf line 18, in resource "azurerm_mssql_database" "sqldb":
│   18: resource "azurerm_mssql_database" "sqldb" {

My terraform plan is:

Terraform will perform the following actions:

  # module.sql_server.azurerm_mssql_database.sqldb will be updated in-place
  ~ resource "azurerm_mssql_database" "sqldb" {
      ~ auto_pause_delay_in_minutes         = 0 -> 60
        id                                  = "/subscriptions/e84af34a-bbd2-4d60-8776-829485d3e735/resourceGroups/rg-terraformtest/providers/Microsoft.Sql/servers/sql-terraformtest/databases/sqldb-terraformtest"
      ~ min_capacity                        = 0 -> 2
        name                                = "sqldb-terraformtest"
      ~ sku_name                            = "GP_Gen5_2" -> "GP_S_Gen5_2"
        tags                                = {
            "environment" = "dev"
            "project"     = "terraform"
        }
        # (13 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

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

Terraform Version

v1.5.6

AzureRM Provider Version

3.71.0

Affected Resource(s)/Data Source(s)

azurerm_mssql_database

Terraform Configuration Files

resource "azurerm_mssql_database" "sqldb" {
  name          = "sqldb-${var.sql_db_name}"
  server_id     = azurerm_mssql_server.sqlserver.id
  tags          = var.az_tags
  collation     = "SQL_Latin1_General_CP1_CI_AS"
  sku_name      = var.sql_db_sku
  max_size_gb   = 5
  min_capacity  = 2
  auto_pause_delay_in_minutes = 60
}

Debug Output/Panic Output

terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.sql_server.azurerm_mssql_database.sqldb will be updated in-place
  ~ resource "azurerm_mssql_database" "sqldb" {
      ~ auto_pause_delay_in_minutes         = 0 -> 60
        id                                  = "/subscriptions/e84af34a-bbd2-4d60-8776-829485d3e735/resourceGroups/rg-terraformtest/providers/Microsoft.Sql/servers/sql-terraformtest/databases/sqldb-terraformtest"
      ~ min_capacity                        = 0 -> 2
        name                                = "sqldb-terraformtest"
      ~ sku_name                            = "GP_Gen5_2" -> "GP_S_Gen5_2"
        tags                                = {
            "environment" = "dev"
            "project"     = "terraform"
        }
        # (13 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

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

terraform aply
module.sql_server.azurerm_mssql_database.sqldb: Modifying... [id=/subscriptions/e84af34a-bbd2-4d60-8776-829485d3e735/resourceGroups/rg-terraformtest/providers/Microsoft.Sql/servers/sql-terraformtest/databases/sqldb-terraformtest]
╷
│ Error: serverless databases do not support license type
│
│   with module.sql_server.azurerm_mssql_database.sqldb,
│   on modules\sql-server\main.tf line 18, in resource "azurerm_mssql_database" "sqldb":
│   18: resource "azurerm_mssql_database" "sqldb" {
│
╵

Expected Behaviour

No response

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

kaganmersin commented 6 months ago

Can anyone look into this issue since it's really dealbreaker ?

kaganmersin commented 6 months ago

Is there anyone who can look this issue as it occurs with a widely used SKU of a very popular database on Azure ? @katbyte @tombuildsstuff

calebak404 commented 3 months ago

Expected behavior should be that if license_type is omitted or set to null, the value in state should change to reflect that.

Currently state persists the previous value, which if it was set before is incompatible with serverless skus. If the value is manually changed in state a subsequent run will apply with no errors.

jason-berk-k1x commented 1 month ago

isn't this a duplicate of #15455 (which seem to have been prematurely closed).

This feel like fallout from the azurerm_mssql_database resource trying to handle all three cases:

  1. a DTU sku
  2. a serverless vCore sku
  3. a provisioned vCore sku

in my experience, I was able to make a module that let the caller switch from serverless vcore to DTU and back w/o issues....but once you switch to a provisioned vCore sku, you can't move off that sku and any attempt to do so will give this errror