Converting information from a spreadsheet into Terraform formatted variable files…part 2!

In part one of this post, I discussed how a simple CSV file containing a list of subnets could be read into a powershell script and and converted into a Terraform configuration file containing those subnets as variables, ready for use in Terraform. This streamlines the workflow and delivery of projects from customer to engineer.

Working with my excellent colleague, Joseph Gadd, he developed a solution in python to take this concept a step further. I do not take any credit for his script as it was all his own work!

The idea of the script is that it can take multiple variable types as input from the spreadsheet, and format them into the correct layout in the terraform configuration file. It can handle simple variable blocks with a description, maps, and lists.

The script is publicly available on my GitHub with Joes permission, it also includes example input and output files. See the readme file for instructions on how to use.

The input spreadsheet looks like this:

… and after conversion, a file is generated, that looks like this:

Information can be gathered easily from the customer, collected in the spreadsheet and be deployed into production in no time!

Hope you enjoyed this article and it helps you to streamline the delivery of your projects!

Originally published at on August 13, 2020.

A blog focused on all things Cloud and DevOps. Specialising in Azure & Terraform!