DEV Community

Cover image for The More I Broke It, The Better I Understood It: My Terraform Breakthroughs
Andrew Muntet
Andrew Muntet

Posted on

The More I Broke It, The Better I Understood It: My Terraform Breakthroughs

Two weeks into the Terraform challenge hosted by the AWS AI/ML UG Kenya, and I can confidently say—it’s been the most tiring yet rewarding learning experience I’ve had in a while.

Big shoutout to the organizers @kevintuei for ensring a seamless learning experience through the community support. This challenge has been such a push, and I’m honestly thankful.

Before this, I had just wrapped up the “Introduction to Cloud Computing” course by the Linux Foundation, which was packed with tools—Terraform being one of them. I barely understood it at the time. I only grasped the general concept of Infrastructure as Code (IaC). But something about it stuck with me.

Fast forward to this challenge, and now Terraform is my daily bread.

We’re working through “Terraform: Up and Running”—a game-changing book, if I’m being real. It doesn’t just introduce you to Terraform—it walks you through it, step by step. You understand why IaC matters, how Terraform declares infrastructure, and you see the big picture while doing the work.

It started off with simple deployments—two servers in AWS. Then state management, workspaces, modules, and now… loops. Every chapter flows naturally, like a guided journey. I began with zero experience, real fear, and tons of confusion—but showing up daily has made all the difference.

But here's the thing that caught me off guard. Somewhere in between all the loops and modules, I paused. I reflected. And I realized there were two big concepts I had completely glossed over. Concepts that once you get, completely change how you think in Terraform:

💡 Creating vs. Referencing Existing Resources in Terraform
🛠 Creating a Resource (from scratch)
resource "aws_vpc" "my_vpc" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "my-vpc"
}
}

➡️ Terraform will create this new VPC in AWS.

🔍 Referencing an Existing Resource

data "aws_vpc" "existing" {
filter {
name = "tag:Name"
values = ["my-existing-vpc"]
}
}
➡️ Terraform will read the VPC (without modifying or recreating it).

That difference—between creating and referencing—was a game changer.

🧠 Understanding Terraform File Interactions
A lot of beginners (myself included) often miss how Terraform files interact. Here’s a clean breakdown:

1. variables.tf – Define your inputs

variable "vpc_cidr_block" {
description = "CIDR block for the VPC"
type = string
}

variable "vpc_name" {
description = "Name tag for the VPC"
type = string
}

2. terraform.tfvars – Supply the values

vpc_cidr_block = "10.0.0.0/16"
vpc_name = "xxxxxxx"

3. main.tf – Use the variables to build your infra

resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr_block

tags = {
Name = var.vpc_name
}
}

  1. outputs.tf – Expose outputs output "vpc_id" { description = "The ID of the created VPC" value = aws_vpc.main.id }

🔄 File Flow Summary
terraform.tfvars ➡ supplies ➡ variables.tf ➡ used by ➡ main.tf ➡ creates ➡ aws_vpc ➡ exposed via ➡ outputs.tf

Once I internalized this, a lot of things made more sense.

This week reinforced a simple but powerful truth: learning DevOps is a marathon, not a sprint. And sometimes, the best thing you can do is pause, reflect, and let the puzzle pieces fall into place.

So, here's to progress, confusion, clarity, and everything in between. I may not know it all yet—but I get it now.

🤝 P.S. What's One Thing in DevOps That Blew Your Mind Recently?
Drop it in the comments—let’s grow together. Cheers.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.