Using Actual Code for IaC
nitric.io
nitric.io
IaC heavily benefits from not being "Actual Code". While DSL based IaC brings in additional constraints that developers hate dealing with, those constraints very frequently map to constraints in the underlying resources and serve as more of a guardrail than a wall.
I've unfortunately been involved in a number of projects where developers moved from "restrictive" dsl based tooling (puppet, ansible, terraform) to tooling that allowed more free-form code to leak in (chef, cdk, unholy in-house nonsense), and every time I've watched the infrastructure description go from something that could easily be tested and reasoned about to an awful mess nobody wants to touch for fear of breakage.
Well-meaning DSL constraints very quickly evolve into hackish defacto "actual code". Every. Time.
I do understand the intent of a constrained DSL mapping to constraints of underlying resources, but more often than not those constraints are short-lived in the lifespan of the DSL, and quickly give way to it becoming a badly architected near-turing-complete programming language.
Ansible (which you've listed) is a prime example: it's not YAML, it's a frankenstein of YAML + logic-heavy Jinja-hacks that really remove a lot of the constraints of pure declarative YAML. The only thing holding it back from becoming a horrible logic mess is very deliberate and well-marketed community convention.
Terraform is getting better at the loops and stuff but I still have a bunch of code from older versions of terraform that are erb templates that output terraform files, thus allowing to use Ruby functions. That was/is probably the least evil solution I've seen. The worst is when the infrastructure or devops team (or someone else) decides, "we need to abstract this away with our own tool."
I'd argue this is one such guardrail. Way more than once I've seen infrastructure resources exhausted (frequently cloud provider limits), because a hard line wasn't maintained between infrastructure code and application code. Frequently in the form of "It just makes sense for us to create one %s infrastructure resource for each %s in our application!" followed by a series of midnight conference calls weeks-months later.
I think those days of magic-HCL-generators are more-or-less behind us.
All we need now is variables in backend config and delayed provider initialisation and we’re laughing !
We programmers have been dealing with this kind of complexity for a long time, why not use some of the tools normally used to manage complexity in code? For example:
1. Comments
2. Code reviews
3. Gated merge requests
etc. etc.
Arguably this comment even demonstrates a bit of what I consider one of the biggest problems in the space. It's common for someone who hasn't bought in to dsl based iac tooling to imply dsl based tooling is from a less sophisticated place where modern engineering practices aren't applied, and it's better to grow up and use big-boy tools.
It's almost like they've forgotten the dsl based tooling was in fact built by other application developers with intense subject matter expertise in the space.
I think declarative should be the default, where practical, for pretty much anything.
If you can't do it in declarative, it's often not a good idea anyway, or the declarative engine just needs an extension.
In the case of nitric we take the requirements given by an application and use a deployment engine we've written using Pulumi to deploy it.
There is potential here to allow hooking into custom deployment engines and internal platform implementations to help standardise the way application developers integrate with cloud resources while still giving platform engineers the control they need.