Org-mode and Terraform
1 minute read
I’m using org-mode to generate the documentation and code to describe and define my project infrastructure. As there are a few different moving parts associated with the things I build I need to be able to get up to scratch with what I’m doing in a few minutes - I can’t afford to lose track of what I’ve done, when.
This post is about how I’m using Literate programming 1 and Infrastructure as Code 2 to support my hobby projects. Here’s a quick diagram of how I’m using a single org-mode file is able to generate documentation and source code:
I’m using Terraform as the IaC tool to manage my infrastructure. To be able to create terraform files from org-mode I’ve:
- Added the Terraform emacs package to my init.org file.
- Created a template org-mode file that saves all terraform code blocks to a specified terraform file on command.
Note that the Terraform major mode package doesn’t support the ability for org-babel to compile and run code blocks within org-mode. This is fine as I’d rather be able to generate a file(s) and run
terraform apply to build my infrastructure in a single step.
Literate programming is a programming paradigm that combines natural language and source code in a single file to define a program. Or something like that. ↩
Infrastructure as Code (IaC) is the process of using files (code) to define what servers (infrastructure) are used to run applications. I hate using the same words in the definition of a term, so here is an entire website about it. I’m using Terraform as my IaC tool. ↩