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.64k forks source link

azurerm_sql_failover_group (sku_name) is not updated when updating azurerm_mssql_database (sku_name) #25706

Open baximan opened 6 months ago

baximan commented 6 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.7.5

AzureRM Provider Version

3.99.0

Affected Resource(s)/Data Source(s)

azurerm_sql_failover_group

Terraform Configuration Files

resource "azurerm_mssql_database" "primary_db" {
  name = "mb_db"
  failover_group = "mb-test-failover-group"
  sku_name = "S12"
} //canadacentral

resource "azurerm_mssql_server" "failover_server" {
  name                  = "failover-sql-server"
  location              = "canadaeast"
  resource_group_name   = "rg-mb-test-for-bank-failover"
  failover_groups = [{                                
      name = "mb-test-failover-group" 
      }]
}

Debug Output/Panic Output

No error. The azurerm_sql_failover_group (sku_name) is simply not updated.

Expected Behaviour

azurerm_sql_failover_group (sku_name) should be updating when updating azurerm_mssql_database (sku_name)

Actual Behaviour

No error. The azurerm_sql_failover_group (sku_name) is simply not updated.

Steps to Reproduce

  1. Create a sql_server
  2. Create 2 databases (primary and secondary)
  3. update the sku_name on primary and run a terraform apply
  4. You'll notice only the promary DB is updated

Workaround: azurerm_sql_failover_group (sku_name) can be updated by the following cli command: az sql db update --name "<database_name>" --resource-group "<resource_group_name>" --server "<sql_server_name>" --service-objective "<sku_name>"

Important Factoids

No response

References

No response

sinbai commented 6 months ago

Hi @baximan thanks for opening this issue. Per the Terraform documentation , "The azurerm_sql_failover_group resource is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the azurerm_mssql_failover_group resource instead.". Could you please use azurerm_mssql_failover_group instead of azurerm_sql_failover_group? If the issue persists, could you please provide a minimal, complete Terraform configuration to help repro/troubleshoot?

userxmen commented 5 months ago

Hi , I have the same behavior" (sku_name) is not updated when updating azurerm_mssql_database (sku_name)" and I'm using the "azurerm_mssql_failover_group" resource with "grace_minutes = 80" and "mode = Automatic".