Replacing deprecated azurerm resources destroy and then create new resources

Hi,
we are using 2 azure resource types: azurerm_function_app & azurerm_app_service which are deprecated and should be replaced by:

  • azurerm_linux_web_app / azurerm_windows_web_app,
  • azurerm_linux_function_app / azurerm_windows_function_app

When I made changes in the scripts and perform terraform plan, it wants to destroy and recreate new resources.
Why is this happening and why terraform doesn’t recognize it’s own old deprecated resources?!
Thanks!

This is expected. Terraform does not have a good compatibility story at all when provider authors decide to deprecate resource types.

It is unfortunately necessary to use terraform state rm to make Terraform forget about the old resources without destroying them, and terraform import to reassociate the actual resources with the new Terraform resource blocks. It’s all quite manual :slightly_frowning_face:

Thanks a lot!
In the meantime I’ve found out that when you change a resource type in terraform it is only possible through create/destroy.
I’ll try with manual interaction with tfstate.