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.6k stars 4.65k forks source link

azurerm_mssql_database always shows a change of license_type even if no change was made #8346

Closed luxiconn closed 1 year ago

luxiconn commented 4 years ago

Community Note

Terraform (and AzureRM Provider) Version

Affected Resource(s)

Terraform Configuration Files

resource "azurerm_mssql_database" "sql_db" {
  name         = sql-db"
  server_id    = azurerm_mssql_server.app_sql_server.id
  collation    = "SQL_Latin1_General_CP1_CI_AS"
  license_type = "LicenseIncluded"
  max_size_gb  = 2
  sku_name     ="Basic"

  extended_auditing_policy {
    storage_endpoint                        = azurerm_storage_account.sql_audit.primary_blob_endpoint
    storage_account_access_key              = azurerm_storage_account.sql_audit.primary_access_key
    storage_account_access_key_is_secondary = true
    retention_in_days                       = 6
  }
}

Debug Output

Panic Output

Expected Behavior

If I don't change anything in the resource terraform should now show the state different than what is deployed

Actual Behavior

Every time we run terraform plan it acts like there is a change in the license type even though no change was made.

resource "azurerm_mssql_database" "camunda_sql_db" {
        auto_pause_delay_in_minutes = 0
        collation                   = "SQL_Latin1_General_CP1_CI_AS"
        id                          = ""
      + license_type                = "LicenseIncluded"
        max_size_gb                 = 2
        min_capacity                = 0
        name                        = ""
        read_replica_count          = 0
        read_scale                  = false
        server_id                   = ""
        sku_name                    = "Basic"
        zone_redundant              = false

        threat_detection_policy {
            disabled_alerts      = []
            email_account_admins = "Disabled"
            email_addresses      = []
            retention_days       = 0
            state                = "Disabled"
            use_server_default   = "Disabled"
        }
    }
}

Steps to Reproduce

  1. terraform apply

Important Factoids

References

neil-yechenwei commented 4 years ago

Thanks for opening this issue. After checked, seems api doesn't return the value of license type. So I raised an issue on Azure/azure-rest-api-specs#10715.

NicolasSeiler commented 3 years ago

@neil-yechenwei Apparently the linked issue is now resolved.

vperaltac commented 3 years ago

Any update on this? The issue raised in Azure was fixed months ago.

dleborgne commented 3 years ago

For what it worths, here is how I workaround this bug :

resource "azurerm_mssql_database" "this" {
  # [...]

  lifecycle {
    ignore_changes = [
      license_type
    ]
  }
}
thllxb commented 3 years ago

Thanks for opening this issue. After checked, seems api doesn't return the value of license type. So I raised an issue on Azure/azure-rest-api-specs#10715.

The LicenseType property does get returned if the database was created using the latest api version.

gerardwolf commented 2 years ago

Any update on this? Still an issue in the 3.7.0 version of the azurerm provider.

fcatacut commented 2 years ago

I'm not running into this issue in AzureRM 3.11.

Terraform v1.0.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/azurerm v3.11.0

Looking at Azure Portal, I believe that license_type only applies to vCore-based purchasing models (e.g. where sku_name is GP_Gen*, BC_*, etc.). Any attempt to set it for any other SKU appears to be ignored by the API.

Note: It looks as if Azure Portal is incorrectly displaying the specified license type. LicenseIncluded is displayed as No whereas BasePrice is displayed as Yes. I confirmed the correct setting is applied using AZ CLI: https://docs.microsoft.com/en-us/cli/azure/sql/db?view=azure-cli-latest#az-sql-db-show.

jaredbrogan commented 2 years ago

Seeing this issue as well. Still happening on provider version 3.24.0.

damiensawyer commented 2 years ago

Come on Hashicorp. 2 Years? Doesn't inspire confidence to start a new project with Terraform.

vanmash commented 2 years ago

Can someone remove "upstream-microsoft" tag, as it seems to be solved already

Perhaps @ArcturusZhang or @tombuildsstuff

jaredbrogan commented 2 years ago

It seems like this may have just been fixed in v3.30.0? https://github.com/hashicorp/terraform-provider-azurerm/pull/19084


UPDATE: Confirmed fixed.

katbyte commented 1 year ago

closing as @jaredbrogan as confirmed its been fixed

github-actions[bot] commented 5 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.