Loops In Tofu Are Weird
|
Note
|
I will refer to OpenTofu in this post, however everything I say applies equally to Terraform. |
Tofu uses HCL to define infrastructure. It’s fairly simple. Closer to a configuration language than a programming language. Choosing a DSL for a product can be hit-or-miss, but in this case I’m fairly pro-DSL. Given the goals of Terraform (the project OpenTofu is a forked from), using something like YAML would quickly become difficult to manage infrastructure at scale, and a full-fledged programming language brings a lot of complexity. While I understand why users of CDKs and Pulumi like it, I think HCL is accessible to more people. I wouldn’t say that HCL is a great language but it gets the job done and is mostly straightforward. Being a simple language meant that we could implement a parser in Ocaml for Terrateam, which let us implement some neat features around code indexing.
IaC and Abstraction
|
Note
|
I will refer to OpenTofu but unless otherwise specified, everything applies to Terrraform as well. |
OpenTofu recently released 1.9.0 with
provider for_each support, also known as
dynamic provider configuration.
This is actually a pretty old request. The
original ticket is from
2019, before even version 1.0.0 of Terraform was released.
A provider is a library that enables Tofu to interact with services. They cover everything from the major cloud providers to services like PagerDuty. To use a provider, you instantiate it with a configuration. The issue is they cannot be referenced through variables, which means the Tofu code can become very repetitive. Dynamic provider configuration addresses this limitation.
Initial Post
Welcome to the pid1.