Best practice (or advice?) about reorganizing Terragrunt directory structure

Hi,

We’ve been happily using Terragrunt for awhile now. We’re using S3 as a backing store w/ Dynamo for locking, as recommend and everything’s great.

I have a desire to re-organize existing resources that are currently organized like:
/whatever/iam/roles/some_role_x/terraform.tfvars
/whatever/iam/roles/some_role_y/terraform.tfvars
/whatever/iam/roles/some_role_z/terraform.tfvars

And what I’d like to do is “push the tfvars file down 1 directory” so that I can have sister directories to manage other assets related to the roles (e.g. role_policies). So my desired end state would look something like this:
/whatever/iam/roles/some_role_x/role/terraform.tfvars
/whatever/iam/roles/some_role_x/role_policy/role_policy_a/terraform.tfvars
etc

My question is - if I create a new “./role” subdirectory and “mv terraform.tfvars role/” and then “terragrunt init” everything seems to work.

Except out in S3, the original “some_role_x/terraform.tfvars” file is still there. I’m hesitant to just delete that because IIRC that causes some checksum problems with the Dynamo locking table?

Is there any advice or best practices about how to move existing/imported assets around in a directory reorg?

Thanks!

Let me reply to myself with a proposed solution and solicit opinions about how terrible of an idea this is:

  • I’ll just delete the S3 /whatever/iam/roles/ directory that holds the master state
  • Delete all the Dynamo keys that reference iam/roles to clear out the checksums of each resource
  • Change my localhost directory structure around to be the way I want it
  • Do a terragrunt import in each of the new directories to re-init / re-create the resources

That shouldn’t cause any side-effects with other un related terraform assets, right? Like, there’s not some sort of “master checksum of all dynamo checksums” that I’d be corrupting all of my terragrunt resources by doing this?

Hi Tvaughn77,

I think the better solution would be to use the terragrunt state mv command to move your state to match what your new directory structure is and then run plan to make sure you don’t see it trying to create/destroy any of those resources that you moved.

Matt