←back to thread

52 points birdculture | 8 comments | | HN request time: 0.001s | source | bottom
1. jamesbelchamber ◴[] No.46182053[source]
"Don't Repeat Yourself" is a great rule of thumb which, at least in writing Terraform configuration, became absolute tyranny. Strange webs of highly coupled code with layers of modules, all in an effort to be DRY - almost everywhere I've seen Terraform.

Trying to explain why a little duplication is preferable to bad abstractions, and specifically preferable to tightly coupling two unrelated systems together because they happened to sort-of interact with the same resource, was endless and tiring and - ultimately - often futile.

replies(6): >>46182179 #>>46182504 #>>46182524 #>>46182757 #>>46182935 #>>46183063 #
2. miduil ◴[] No.46182179[source]
testability and developability, ideally you structure your terraform/terragrunt code in a way that you can bootstrap an almost equivalent test environment. For example when using "AWS Well Architected"-method you would be able to bootstrap a similar environment on a separate AWS account that's part of your organization.

Unfortunately, terraform module system is extremely lacking and in many ways you're totally right - if your module is just replicating all the provider arguments it just feels wrong.

3. esafak ◴[] No.46182504[source]
Were they deduplicating incorrectly, or does terraform lack the ability to do so well?
replies(1): >>46182882 #
4. hbogert ◴[] No.46182524[source]
you can shorten to:

> writing Terraform configuration, became absolute tyranny.

5. gaigalas ◴[] No.46182757[source]
Explaning is hard. Examples often work better. You need to be able to show an example where deduplication would be made worse by applying DRY, otherwise it's hard to argue using just vague descriptions.

I totally agree with deduplication, but only when it's shown. Otherwise it's too easy, and I've seen people try to use this argument to justify slop many times.

6. baby_souffle ◴[] No.46182882[source]
Bit of both, really. There are some common techniques that would be a lot simpler or more robust if terraform would support variables and expressions like lambdas in more places (tofu is getting there…) but it’s also a failure to realize that terraform is ,rant to composite many small modules together and not just pass 150 different inputs into an Omni module.
7. hinkley ◴[] No.46182935[source]
On the terraform comment, things that change together ship together is a good mantra.

If you keep having to make edits in two independent systems every time you want to make one change, something is wrong. If you’re leaving footguns around because changing one thing affects two or more systems, but you aren’t at liberty to change them both in production, that’s also something wrong.

8. Ekaros ◴[] No.46183063[source]
I don't do too much terraform. But isn't the DRY really happening on provider level? And when you are using it, most of times it really doesn't make too much sense to try to not repeat yourself. Unless you are dealing with actual identical resources. Or deploying multiple times say dev, test and prod.