Skip to content

Prevent hcl files everywhere with smart projections #3258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks
cveld opened this issue Jul 11, 2024 · 1 comment
Closed
2 tasks

Prevent hcl files everywhere with smart projections #3258

cveld opened this issue Jul 11, 2024 · 1 comment
Labels
pending-decision Pending decision from maintainers rfc Request For Comments

Comments

@cveld
Copy link

cveld commented Jul 11, 2024

Summary

We really like terragrunt as it helps us keeping our codebase dry.
Although terragrunt could go one step further -
Currently we have a setup where every terragrunt component has more or less the same terragrunt.hcl.
It would be super if there would be way to instruct terragrunt that a particular folder has a specific range of components, that are all using the same terragrunt.hcl without having to layout all those folders and copy the very same terragrunt.hcl everywhere.

Additionally, it should be possible to add hcl on top this baseline folder hcl.

Motivation

Terragrunt is really helpful in keeping our code DRY, but currently we suffer from having the (almost) the same hcl files everywhere.
We would really like to slim down the amount of repeated code as much as possible.

Proposal

Although most probably not the best solution, but it could work:

  • container-folder / .terragrunt-template.hcl
  • container-folder / .terragrunt-components.yaml
  • container-folder/ subfolder-component3 / additional-config.hcl

.terragrunt-components.yaml should contain a list with all desired components (separate terraform states):

- subfolder-component1
- subfolder-component2
- subfolder-component3

.terragrunt-template.hcl contains the base hcl config that is executed for every specified component.

In this example only subfolder-component3 requires additional config and is provided by additional-config.hcl.

Technical Details

tbd

Press Release

Terragrunt is a great tool to keep your terraform code DRY! With the latest version of terragrunt this got even better. Our original codebase contained a lot of copies of the very same hcl file. And now with the sophisticated template projection feature we were able to consolidate into one parameterized template.

Drawbacks

Terragrunt code can become even more abstract and complex.

Alternatives

Add a prepare step before running terragrunt and copy and merge files with classic file copy and merge operations.

Migration Strategy

At least manually someone can identity repeating hcl files and consolidate them into this new template projection feature.

Unresolved Questions

tbd

References

tbd

Proof of Concept Pull Request

tbd

Support Level

  • I have Terragrunt Enterprise Support
  • I am a paying Gruntwork customer

Customer Name

No response

@cveld cveld added pending-decision Pending decision from maintainers rfc Request For Comments labels Jul 11, 2024
@yhakbar
Copy link
Collaborator

yhakbar commented Aug 2, 2024

Hey @cveld ,

Take a look at Stacks which attempts to solve this problem in a slightly different way. If you like that approach, consider leaving your reaction or feedback there, then closing this RFC.

Thanks!

@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-decision Pending decision from maintainers rfc Request For Comments
Projects
None yet
Development

No branches or pull requests

2 participants