2

I have a set of resources in resource group A and would like to move to resource group B. I know it is doable with azure cli but is it possible to do that in terraform?

The reason I ask is I don't want to do two steps action here:

  1. Create a resource group B in terraform
  2. Trigger a script to migrate resource from group A to group B.

Just want to see if Terraform provide such functionalities to do everything in a terraform script.

Kintarō
  • 2,947
  • 10
  • 48
  • 75
  • Based on this: https://github.com/hashicorp/terraform-guides/issues/232 3-step approach should work: Use Microsoft's API, CLI, or powershell to move the resource to a different resource group. Then modify the Terraform configuration to use the new resource group in resource_group_name. Run terraform refresh against the workspace or configuration to force Terraform to update the state file with the new resource group. – tomarv2 Mar 10 '22 at 02:57
  • 1
    Check out aztfmove, a simple tool to move Azure resources based on Terraform state.It does exactly what you are describing, moving resources based on Terraform state to different resource groups or subscriptions in Azure.: https://github.com/aristosvo/aztfmove – RahulKumarShaw Mar 10 '22 at 09:16
  • Please refer this Link as well it may help you :https://stackoverflow.com/questions/69283041/terraform-move-entire-resource-group-to-new-azure-subscription#:~:text=It%20is%20NOT%20possible%20to,subscription%20terraform%20workspace%20is%20futile. – RahulKumarShaw Mar 10 '22 at 09:18

1 Answers1

0

Yes moving resource from one resource to another resource can be possible with one of the tool called aztfmove.

aztfmove Simple tool to move Azure resources based on Terraform state

It is sometimes inevitable to move Azure resources to a new subscription or to a different resource group within an Azure Tenant. This means often a painfull transition when all resources are already in Terraform.

To combine both the joy of Terraform and the movement capabilities within Azure, this tool gives you the capabilities to migrate quick and easy.

You can download this tool from this github link and can be install with

go install github.com/aristosvo/aztfmove.

For more information how you can use and for example you can refer the same above github link.

RahulKumarShaw
  • 4,192
  • 2
  • 5
  • 11