News for hackers. Stuff that matters.
Re:Terraform Config Root Setups by dayallnash on Sunday February 16, 2025 @07:15AM (#43067448)
Terragrunt goes a long way to providing a near-perfect way to structure Terraform repos.
Re:Terraform Config Root Setups by spicyusername on Sunday February 16, 2025 @08:37AM (#43067857)
I didn't understand the benefit of using terragrunt. Modern terraform supports all of the features terragrunt was originally designed to work around way back when.

Outside of being able to use variables in very niche places that you can't in terraform (and can easily work around, and that last I heard is on the road map for open tofu), what does terragrunt do that using regular module imports in terraform don't?

This may be anecdotal but every terragrunt repository I've ever seen was a mess of spaghetti trying too hard to stay DRY.

Re:Terraform Config Root Setups by slillibri on Sunday February 16, 2025 @11:20AM (#43069177)
1) I use terragrunt to generate all the 'boilerplate' files, for example the backend configuration to ensure they are all in spec.

2) I use terragrunt to provide inherited values, such as region, environment, etc. I have a directory tree of `dev/us-west-2/` I can set a variable in my `dev/environment.hcl` that is inherited across everything under that environment. This is useful if you have more than one dev, prod, etc environment.

3) I use terragrunt to allow shared, versioned root modules. I don't include any terraform in my terragrunt repo. The terragrunt repo is just configuration. In my terragrunt.hcl I can reference something like `source = "github.com/example.com/root.git//ipv6-vpc?ref=v0.1.3"` to pull in the version of the root module I want. Again this is useful if you have multiple dev/stage/prod environments.

None of this is actually possible with plain terraform.

Re:Terraform Config Root Setups by spicyusername on Sunday February 16, 2025 @09:33PM (#43074365)
This is exactly what I'm talking about.

Using variables isn't supported in backends - e.g. "niche places" (although it sounds like it is in OpenTofu)

And #2 and #3 are exactly the use-case for just regular old tfvars files and module imports.

Terragrunt encourages you to abstract things way, way too far, until you have an absolute mess of tangled imports and deeply nested directories.

Nothing wrong with having a root module, some child modules, and a single tfvars file being fed in on the front end.

Re:Terraform Config Root Setups by cube2222 on Sunday February 16, 2025 @10:27AM (#43068739)
Not just on the roadmap!

With OpenTofu as of the latest release you can already use constant variables in places like module sources and versions, backend configurations, and even in order to for_each on providers!

Disclaimer: involved in OpenTofu

Re:Terraform Config Root Setups by cyberpunk on Sunday February 16, 2025 @10:22AM (#43068694)
Pain and suffering lies behind any attempts to make tf DRY. Unless you have a really insane amount of envs, I just copy/pasta these days. Fuck it. Life is too short.
Re:Terraform Config Root Setups by joshpadnick on Thursday February 20, 2025 @12:27AM (#43111413)
I'm from Gruntwork; we're the maintainers of Terragrunt.

We get this question a lot because Terragrunt did in fact start as a feature shim for Terraform. But that was a long time ago and Terragrunt has evolved into a first-class "orchestration" tool for Terraform or OpenTofu.

We wrote a blog post addressing exactly your concern that you might find helpful: https://blog.gruntwork.io/terragrunt-opentofu-better-togethe....