- Random Access Musings
- Posts
- Diving into Terraform
Diving into Terraform
Your Lexicon for Infrastructure as Code

Hello Muser!
Transitioning from general system administration to DevOps/SRE roles can feel like learning a new language. Especially when you stumble upon tools like Terraform that are central to Infrastructure as Code (IaC) practices. But, you’ve already got a knack for automation with Ansible, and Terraform is just another tool in the box. Let’s decode some of Terraform's vocabulary, so you’re not lost in translation.
Let me know if I’m missing something from this list in the comments!

Terraform Configuration
This is your blueprint. Just as you defined playbooks in Ansible, in Terraform, you’ll pen down configurations. These are text files that describe the infrastructure you want.
Check out the basic syntax to get started. It’s the grammar book for Terraform.

Provider
Remember how in Ansible, you needed specific modules to talk to different systems? Terraform has something similar called providers. They are plugins that allow Terraform to interface with various services like AWS, Azure, or even GitHub.
Dive into the provider docs to see how these work.

Resource
Resources are the most essential aspect of a Terraform configuration. They represent infrastructure objects like a VM instance or a database.
It’s similar to how you'd define tasks in an Ansible playbook.

State
Terraform keeps track of your infrastructure's state in a file. This is how it knows what exists and what changes to make, like a map to the infrastructure treasure.
State management is crucial. Take a peek at how Terraform handles state.

Plan & Apply
Before making any changes, Terraform gives you a plan, showing what it intends to do. Once you approve, the ‘apply’ step makes the actual changes.
The plan step is like running Ansible with
--check
flag, giving you a heads-up before anything happens.

Output Values
After Terraform does its magic, it can output information you might need, like IP addresses or DNS names.
Similar to registering variables in Ansible, outputs help you capture useful info from the actions Terraform performs.

Modules
Just as Ansible roles let you bundle automation content, Terraform modules let you encapsulate configurations. A module can be used in multiple configurations, promoting reusability and organization.
Dive into modules to discover how to make your configurations more modular and reusable.

Workspace
Workspaces help you manage multiple environment configurations like staging or production within the same configuration.
This might remind you of Ansible’s inventory files, helping you tailor the behavior based on the environment.

Here’s a tiny example to give you a feel for how these elements come together in a Terraform script:
provider "aws" {
region = "us-west-2"
}
resource "aws_instance" "example" {
ami = "ami-abcdefgh"
instance_type = "t2.micro"
}
output "instance_ip" {
value = aws_instance.example.public_ip
}
In this snippet:
We’re specifying the
provider
as AWS and the region where our infrastructure will reside.We define a
resource
of typeaws_instance
namedexample
, setting some basic attributes.Finally, we define an
output
to capture the public IP of the created instance.

Here’s how these terms interconnect to form a coherent script.
Your Terraform Configuration (code) contains
Providers that tell Terraform how to talk to your desired cloud,
Resources that are the actual infrastructure you're provisioning,
and Output Values to capture useful info.
When you run
terraform apply
,Terraform checks the State to understand the current setup,
generates a Plan showing you the proposed changes,
and upon your approval, applies the changes.
If you have repetitive configurations, bundle them in Modules for reuse
and manage different setups using Workspaces.
It’s a well-oiled machine, where each part has a role, making your transition into the cloud orchestration world smoother.

Just like when you were getting familiar with Ansible, understanding the vocabulary is a solid step toward mastering Terraform.
Remember, every tool has its quirks, and Terraform is no different. But with your background, you're more than equipped to dive in and start orchestrating your infrastructure with Terraform.
Enjoyed this post? Don't miss our next one where we'll keep exploring Terraform and how to actually start using this tool! Subscribe now and share with your colleagues who might find this useful!
Have any questions or experiences to share about Terraform? Leave a comment below. Also, your comments help me understand what you're curious about, and what topics you'd like to see covered next! I'd love to hear from you!
Keep learning and keep growing,
Reply