terramate-io / terramate

Terramate CLI is an open-source Infrastructure as Code (IaC) Orchestration and Code Generation tool for Terraform, OpenTofu and Terragrunt.
https://terramate.io
Mozilla Public License 2.0
3.12k stars 85 forks source link

[FEATURE] Use Clone feature to overwrite stacks, but keeping stack IDs. #1779

Open solovyevt opened 5 days ago

solovyevt commented 5 days ago

Is your feature request related to a problem? Please describe. One convenient use-case for Clone feature is to promote environment stack, e.g. staging -> prod, but currently it's not possible due to one-time nature of terramate clone.

Describe the solution you'd like A useful improvement would be a --sync or --destructive flag that will allow to run terramate clone on existing folders and synhcronize everything, but keeping stack.id field intact.

Describe alternatives you've considered I've been using a custom script that did the following:

  1. Parse the stack.id field, store in a variable
  2. Remove existing target directory
  3. Run terramate clone
  4. Set stack.id field

Additional context It might be wise to think about additional field that would be preferable to store, e.g. stack.description or stack.name, but I will leave this to maintainers.

P.S. Thank you for your great work.

soerenmartius commented 5 days ago

Thanks for suggesting this! We were actually thinking about similar use-cases. Let me discuss this with the team and get back to you!

i4ki commented 4 days ago

What is the difference between terramate clone keeping all stack ids intact and plain cp -R from/stacks to/stacks ?

solovyevt commented 1 day ago

@i4ki Currently terramate clone can be executed if the target folder does not exist, so it copies the source stack and it's nested stacks and generates new IDs.

Now, the requested feature should allow to execute terraform clone even if the target folder exists, and, naturally, you would want for the current target stack IDs to be preserved, while all other content is overwritten with the contents of the source stack.