How to handle folder moves in Terragrunt?
I would like to rename a folder in my Terragrunt project, but since the remote state path is tied to the folder path, how can I do this in a way such that the state is preserved? --- <ins datetime="2022-07-18T13:47:27Z"> <p><a href="https://support.gruntwork.io/hc/requests/109002">Tracked in ticket #109002</a></p> </ins>
The best way to do this is to move the state file using `state pull` and `state push`, one module at a time. This is tedious, especially if you are moving a folder in the middle of the tree, but it is much easier to guarantee the state files remain intact. To do this while keeping state, for each module do the following: - Dump out the state to a known, temporary location using `terragrunt state pull > $PATH_TO_TEMP_LOCATION` (where `PATH_TO_TEMP_LOCATION` is a file path, e.g. `/tmp/temporary_state.tfstate`). - Make the change to the filesystem, moving the module to the desired folder location. - In the new folder, import the state using `terragrunt state push $PATH_TO_TEMP_LOCATION`. - (Optional) Remove the state file from the old path in the remote state location using the AWS CLI or AWS web console.