Not sure about that. It’s a clever trick alright but it adds a possibly unnecessary layer of leaky abstraction and makes code reuse more difficult when working with “vanilla” Terraform. If you really want to use a full programming language with infra as code, I’d suggest looking into Pulumi. Or, if you want to (or need to) stick to Terraform, try the official CDK.
What I don’t get about “modern” development is lack of complexity management.<p>It feels like 8 degrees of work to write HCL that any component developer can do.<p>What maddened me was the lack of support for the count parameter for modules. Made me rage. But not enough to switch to tools like this or troposphere.<p>Not to mention the supply chain implications and security risk that comes with it.
Terraform added a lot of these procedural functions natively in the time since this was created.<p>At any rate if you want to stick with Python, I'd say Pulumi would be a safer choice these days.
I find cue lang [1] very practical/useful/terse, their idea of lattice based type system is very intuitive and expressive with very little code.<p>[1] <a href="https://cuelang.org/" rel="nofollow">https://cuelang.org/</a>
Does anyone know if there's OSS projects we could use to replace Terraform with Python + boto3? I specifically do not want to use Pulumi. The dependency validation wouldn't be too hard to implement, but all the inter-resource and feature-specific logic would need to be duplicated.<p>The reason I won't use Pulumi is 1) licensing and 2) corporate ownership. I'd rather use CloudFormation.
Kapitan allows you to achieve the same using (python) Kadet to compile JSON tf files <a href="https://kapitan.dev/compile/#kadet" rel="nofollow">https://kapitan.dev/compile/#kadet</a>
Why not just use Python to create the "things" in whenever you need to create them in the first place?<p>Just write the code taking idempotency in mind, and no reason to use Terraform at all.