The new refactoring feature can help when (many times) you find a better module but you don’t want to go through the shuffle of the mv command. I liked one scenario explained in the demo which was the decoupling a web config from a specific cloud provider module to a module that can be used for multiple clouds done without the mv command and less risk.

Demo Summary:

If you change your template and move or rename a resource group then all things will be destroyed since TF will interpret that since the RG is no longer in the main module then it needs to delete it. Resourge group deleted = All things are deleted.

Unless we use the new refactoring feature as seen below. It doesn’t have to be in a separate file.

Previous method: Move

First this is that you will lose history and warnings:

source: https://www.terraform.io/cli/commands/state/mv

Video: