`terragrunt stack clean` removes local statefiles
$ terragrunt --version
terragrunt version v0.78.0
When using local statefiles, the terragrunt stack clean command removes the entire .terragrunt-stack directory structure, including all state files. I use local statefiles when testing my iac components. I can't clean the generated directory structure without first running tf destroy.
I open this issue more as a question of "is this desirable or not?".
Hey @mhulscher ,
Yes, it's intended. Is there alternate behavior that's preferred?
@yhakbar I would prefer if the clean command only removed files (not directories) that were generated by terragrunt. So if I refactor my terragrunt.stack.hcl to rename a unit or stack, I would like clean to remove those directories' terragrunt.hcl, but not necessarily their state.
Right now, there doesn't seem to be a way to iteratively generate the unit tree, except for running clean followed by generate.
When doing local development, I tend to update my root terragrunt.stack.hcl quite a bit, followed by running terragrunt stack generate, and without running clean first, generate leaves lingering units that may have been removed or renamed.
@mhulscher ,
That really isn't in the design of how Stacks were intended to function. The .terragrunt-stack directory is intended to be OK to fully regenerate on-demand based on a terragrunt.stack.hcl file. I think we can improve our documentation to help users mitigate issues related to loosing local state files from regeneration of .terragrunt-stack directories, but it's not going to involve selectively avoiding removal of state files.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.