I always start with a Terraform module

Published June 11, 2024

Terraform or OpenTofu is my way to go when it comes to Infrastructure as Code. I tend to simplify everything to it.

AWS? Terraform Provider
GCP? Terraform Provider
Kubernetes? Terraform Provider
But what about Helm? Terraform provider
But what about Flux? I said Terraform!

Do you like Terraform? No, I don’t like Terraform, but it gets things done quickly.

My strategy is to always create a Terraform Module, if it is a small project at the end my main.tf will have the initialization of one module and that’s it.

I do that because a module helps to define a scope. It forces declaring variables, to define outputs.
The worst that can happen is that you will never use it again.

It almost never happen, as soon as the company turns a bit serious they will ask you to create a new environment for your developers to do testing, or for the contractors developing the web application. Or for the CEO that needs a safe, slow moving version of the application to demo to potential customers.

Usually I keep out from the module the DNS configuration because it is a resource frequently shared across the board. The module exposes the IPs I need to configure new DNS records as output, and then I do it.

Are you having trouble figuring out your way to building automation, release and troubleshoot your software? Let's get actionables lessons learned straight to you via email.