Terraform - The GOOD

It’s a really good promise and for the most part well executed — define your infrastructure in easy to read syntax, run terraform plan to see what it intends to do, run terraform apply to do it!

Terraform Consul cluster setup end result

All providers are run in parallel. You can spin up 20 servers in no time at all.

It uses the magic of dependancy graphs to figure out what it needs to do and in what order. This means that if you set a security group to an instance, it will create the security group first. You don’t need to think about the order of things, it does it all for you.

So Consul requires 3 servers to run for production setup. But there’s a catch. When bootstrapping the cluster you need to reference an existing server for Consul to be able to connect to it and establish quorum. Terraform helps if we reference first server in a provisioner. It will spin up and provision the first server to get its IP and then proceed to setup all others, in parallel, using that IP. Very nice.

It has partial state which essentially means that it will try to pick up from where it left off in case of errors.

Integration with HashiCorp’s Atlas means you can push Terraform files to them, they will run the plan and if successful, you can apply it via their GUI. It gives you an ability to collaborate on infrastructure with others and more importantly, full change history.

Additionally adding Consul to Atlas means you don’t need to run Consul UI yourself.

Outputs are a handy way to print some data on screen after successful apply. See above.

You can use terraform destroy to vaporize your environment in seconds. Very handy for testing.

Terraform — The BAD

Variables and variable interpolation is absolutely horrid. Stupid things like no arrays for variables, interpolation working in some places but not in others, absolutely no way to debug variables and interpolations. Most of the time I spent battling this. Very frustrating. HashiCorp would benefit from some developer UX love in this area. As a user I don’t care how complex things can be under a simple interpolation. It should just work.

Terraform will load all *.tf files in a directory. This doesn’t work for sub-directories though — which brings us to Modules.

In order to group things in folders you need to use modules and it’s a really weird thing. Module has it’s own scope so you need to re-define a lot of variables and specify their value in a module definition.

Blah.

I didn’t find a better solution but if anyone knows it, please comment.