So, Terraform is a cool infrastructure-as-code system with a boatload of functionality. It makes building out entire clouds on AWS1 super easy and super fun. I am a fan. I started my new job as Lead Platform Engineer at Leaf this week2, and I was really happy to have the chance to use Terraform in a greenfield project where I could play with it.
But I wasn’t happy with it, and so I’ve done a thing.
As a tool, Terraform is pretty good. It’s smart, it does the right thing when it comes to figuring out how to best apply your plan to your environment. But I had a real beef with it. Ever since HashiCorp went away from Ruby DSLs as configuration in their various projects, I have been sad. And worse than sad, I have been unproductive. I don’t like Packer’s config format and I really am just not satisfied with the state of the Terraform language’s3 grammar and semantics. It’s hard to write, its built-in assumptions are gross (the handling of variables is a minor crime in progress), and it’s just a huge step back from being able to deploy, say, a Vagrant instance–or, as I have done, a configurable number of Vagrant instances–in a nice, comprehensible manner.
So I did it. I broke out ye olde Ruby interpreter and, in the next three hours, out of my fingers came Terraframe, a tool that I think makes Terraform about a billion times nicer to use. It accepts any number of Terraframe scripts (themselves just Ruby files) and any number of YAML files (merged in sequence) and spits out a Terraform JSON file out of them4.
Terraframe isn’t at all done, so don’t expect miracles (yet) and there are probably all sorts of bugs because I’m still new to Terraform, this hasn’t been used in anger, and this is the first time I’ve ever used Ruby to write a DSL, but it’s performed fine in setting up the test cloud I’m building at Leaf. I’ll begin extending it over time—I’ll add provisioner smarts to it when I start needing provisioners, that sort of thing—and I’m sure I’ll fill it out further over time. You can get it on Github or download v0.0.5 via RubyGems with
gem install terraframe.
Contributions, as usual, are welcome.
Leave a Reply
Click here to cancel reply.