Wyatt Peterson manages the Production Engineering team at NerdWallet. In previous incarnations he focused on Big Data and data infrastructure in addition to working on continuous deployment at IMVU. He enjoys working with Python and has used it for tooling, web services, and map/reduce jobs among other things.
At NerdWallet we are heavy Terraform users, but we don't use HCL (the native Terraform language) to build our resource definitions -- we use Python! This talk will cover the motivation for using Python and details of the implementation of how Python is converted into Terraform definitions.
Terraform is an amazing tool. Like, really amazing. When working with code that is managing third-party service definitions, and actually applying changes to those definitions by invoking APIs, a high-degree of confidence in the change process is a must-have, and that's where Terraform excels. The work flow it empowers allow teams to quickly make changes across a large (and ever growing) footprint in multiple providers/regions/technologies/etc.
But as your definitions grow the HCL syntax very quickly leaves a lot to be desired, and oh-my-gosh is it verbose... So many definitions of variables and outputs need to be repeated, over and over, as you compose more modules that use each other. Also, since HCL is a language built at Hashicorp specifically for Terraform it has an immaturity about it that is just the fact of the matter about a young language.
Nestled in the Terraform docs there is a section on a JSON syntax. Well... building JSON from code is something we're pretty good at in Python!
At NerdWallet we have built a custom Python abstraction that allows us to build Terraform definitions in a manner that feels very similar to HCL, so that we can apply examples from the documentation, while still giving us the full power of Python to do more complicated data manipulations & transformations.