Refactoring Terraform easily with moved block
As Terraform codebase grows, there are chances where you may need to refactor or rename resources in your codebase which can result into deletion and recreation of resources. This happens because terraform thinks that you want to delete and create new resource and it allocates new id to the resource. Instead, you should let terraform know that you want to simply move the resource instead of replacing it. To mimic this we will take simple example where we will have AWS instance with name a and we want to change it to b ...