How do I use a Terraform `move` block to move an Azure SQL Database to a different resource name?

I’ve been able to move SQL Alerts between resource names in my terraform, for example:

moved {
  from = module.myproj_sqldbs.azurerm_monitor_metric_alert.alert_storage_percentage_exceeds_80["mydb"]
  to   = azurerm_monitor_metric_alert.alert_storage_percentage_exceeds_80    
}

The above results in a ‘replace’ when running a terraform plan

However, an equivalent move for my SQL DB:

moved {
  from = module.myproj_sqldbs.azurerm_mssql_database.sql_database["mydb"]
  to   = module.sqldb.azurerm_mssql_database.sql_database
}

Yields the following error:

╷
│ Error: Unsupported `moved` across resource types
│
│   on imports.tf line 10:
│   10: moved {
│
│ The provider "terraformregistry.mycompany.com/hashicorp/azurerm" does not support moved operations across resource types and providers.
╵

I thought maybe it was treating them as different resource, types, but I don’t think that’s the case. I.e. Without this, the plan indicates the following:

# module.sqldb.azurerm_mssql_database.sql_database will be created
......
# module.myproj_sqldbs.azurerm_mssql_database.sql_database["mydb"] will be destroyed

I’ve also noticed, that it’s relying on the ‘mycompany’ registry. Could that be a thing?

Read more here: Source link