DEV Community

Anna Aitchison
Anna Aitchison

Posted on

Yamlless Infrastructure as Code

If Yaml had a tech CV, recuiters would kill to place it. Just look at some of projects it's been a key part of across its star studded career:

✅️ Kubernetes
✅️ AWS CloudFormation
✅️ Ansible
✅️ GitHub Actions
✅️ Azure DevOps

Or in slightly more sensible terms; pretty much every single DevOps tool has own configuration language, and many are based on YAML. These languages usually express a great deal fairly simply, so the initial learning curve isn't too steep. However, the problem arises when you start trying to express high levels of complexity with them. Simple things that you'd take for granted in a normal programming language like conditional statements, loops, and text operations, may exist in some form, but quality varies a lot, they aren't necessarily particularly easy to understand or discover, and the result can be an alphabet soup that's near impossible for humans to parse without deep subject knowledge.

However, at least in Infrastructure as Code, you can actually use general purpose programming languages. This is by no means a cure all but for some people, like me, it might well be a more pleasant option. There are two options that I'm aware of; AWS Cloud Development Kit (which comes in three variants for: AWS only, Terraform and Kubernetes) and Pulumi, which seems to be Terraform based, not an AWS person, there are other options too; there are variants of it for Kubernetes and Terriform and a completely different project called Pulumi, which seems to be Terraform based. I've honestly only worked with the AWS only version of the CDK, so I'll fcus on that, but the other three options should be much the same. Love to hear from anyone who's used the other versions.

The way it works internally is really intresting; they wrote a whole framework for translating between languages so they can have just one codebase and support TypeScript, JavaScript, Python, Java, C# or Go with modules in each programming language, and the end result actually gets written out as CloudFormation Yaml, so you can use that directly if you have to.

This approach to Infrastructure as Code obviously has its own complexities, and you need to know one of those languages already to get the best out of it. The one problem that I mainly encountered with the CDK was that the documentation isn't necessarily the best, but IDE completion is available, the code is opensource and the team are super helpful if you raise a GitHub issue. It's not necessarily for everyone, but is well worth checking out if you relate to my little rant about Yaml and friends.

First blog post in a while, I'm trying to take this a bit more seriously than before so feedback is welcome :)

Top comments (0)