No Terraform No Life
By Hima
I have an opinion that might be controversial (or not). Personally, if you're not implementing or touching Infrastructure as Code (IaC) as part of your codebase, you can't be considered to have DevOps experience. You're at best a glorified cloud console clicker.
Introduction
In the past, when I was at different companies many years ago, there was no concept of IaC. We were clicking consoles, and if we needed to spin up new resources? Log into our AWS or GCP and start clicking about. If something needed to be deprovisioned? We'd do it manually too.
In retrospect, after thinking back, I was left wondering why IaC was not more emphasized as part of our software development lifecycle, considering that we have version control for our codebase, but not our infrastructure? They should be going hand-in-hand and it just makes the developer experience and life much easier.
Why Terraform Changed Everything
One day, just like anyone bored and curious, I went searching for what could make my life easier, because I knew intuitively that clicking around consoles wasn't the way. What if we had a script that could call the AWS API to spin up resources and configure them based on my needs? What if I had multiple projects and wanted to spin up a fleet of these resources with the same configuration? All I'd need is to write a script and press one button. Enter Terraform.
So what's so good about it that it solves many developers' problems and streamlines the experience for us?
1. Infrastructure as Documentation
Your Terraform code IS your infrastructure documentation. Not sure about something? Don't have to worry about navigating through the unintuitive cloud console. Your infrastructure state is all defined in code.
resource "aws_instance" "web_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t3.micro"
tags = {
Name = "production-web-server"
Environment = "production"
Owner = "platform-team"
Purpose = "serves-api-traffic"
}
}
Look at that. In just 10 lines and at a glance, I know more about this server than I would from having to spin up my browser, log in, navigate to different console screens, fumble around for the configurations and settings.
2. Version Control for Infrastructure
As mentioned earlier, if you have version control for your code base, it does not make sense to not have version control for your infrastructure.
With IaC, your infrastructure has a history. You can see who changed what, when, and why. You also have a reproducible state that you're able to roll back to different versions if something goes wrong.
For fellow developers, I don't think I need to explain further why this is the biggest win.
3. Reproducibility at Scale
Expanding from point 2, if you need to spin up a new environment? With ClickOps, that's a 2-day ticket involving screenshots, documentation, and probably several "wait, what setting did we use for that?" moments.
With Terraform:
terraform workspace new staging
terraform apply
Done. Identical infrastructure, different environment, I know what I created exactly, I can refer back, and I know what I need to destroy when the time comes.
Final Thoughts
I've been running most if not all my projects with proper Terraform state so that whenever I make a merge, even if it's a feature that requires provisioning or deprovisioning a resource, my CI will make sure to do it automatically without me having to do anything other than simply merging the branch into main.
As a developer, I personally think that it's extremely important to have proper infrastructure and pipeline set up so that we as developers can fully commit to the technical aspects of the codebase and feature implementations instead of context switching to other aspects of the project that we could have simply automated.
