Problem
Terraform is forcing a replacement of the database when the collation attribute of the azurerm_mssql_database resource is the same, but with capitals:
Terraform will perform the following actions:
# azurerm_mssql_database.primary_db must be replaced
-/+ resource "azurerm_mssql_database" "primary_db" {
~ auto_pause_delay_in_minutes = 0 -> (known after apply)
~ collation = "SQL_Latin1_General_CP1_CI_AS" -> "SQL_LATIN1_GENERAL_CP1_CI_AS" # forces replacement
Cause
As per the Microsoft SQL Server Database official documentation here it is stated that the collation attribute is case sensitive:
The options associated with a collation are case sensitivity,
accent sensitivity, kana sensitivity, width sensitivity,
and variation-selector sensitivity. SQL Server 2019 (15.x)
introduces an additional option for UTF-8 encoding.
Solutions:
- The Terraform code should be updated accordingly so there is no drift detected.
- The lifecycle configuration block with the ignore_changes can be used to stop Terraform to force a replacement and instead is going to ignore any changes for the collation attribute.