Handling Unsupported Move Operations in Terraform
Date published:
Managing infrastructure as code (IaC) with Terraform is a powerful way to ensure consistency and repeatability in your deployments. One common issue that arises is the error:
The provider ‘registry.terraform.io/hashicorp/azurerm’ does not support moved operations across resource types and providers
In this post, we’ll explore why this happens and how to handle it.
Understanding the Issue
When you attempt to move resources across different types or providers in Terraform, you might encounter the error mentioned above. This typically occurs when you’re trying to transition resources from an old configuration to a new one, such as moving from a module to a standalone resource or changing resource types.
Why Does It Happen?
Terraform’s move
block is designed to handle renaming or relocating resources within the same type and provider. However, it does not support moving resources across different types or providers.
Example Scenario
Let’s say you’re using Terraform v1.9.8 and you want to move a resource from an old module to a new standalone configuration. You might encounter the following error:
Error: The provider “registry.terraform.io/hashicorp/azurerm” does not support moved operations across resource types and providers
How to Handle the Issue
To work around this limitation, you can follow these steps:
-
Remove the Old Resource:
- First, remove the old resource from your Terraform configuration. This will ensure that Terraform no longer manages the resource in its current state.
-
Import the Resource:
- Next, import the resource into the new configuration. This allows Terraform to manage the resource in its new state without having to destroy and recreate it.
Solution
The best way to handle this issue is to remove the old resource from the configuration and import the resource into the new configuration. This allows Terraform to manage the resource in its new state without having to destroy and recreate it.