Skip to content
tezvyn:

Terraform: Manage Infrastructure as Code

Source: developer.hashicorp.comEasyHow cards are made

Terraform: Manage Infrastructure as Code

Terraform lets you define cloud infrastructure—servers, databases, networks—in a text file, like a blueprint. It reads this file and builds everything for you, making setups on AWS, GCP, or Azure repeatable.

Why it exists

Before Infrastructure as Code (IaC), managing servers and networks was a manual process of clicking through a cloud provider's web console. This was slow, error-prone, hard to reproduce consistently, and impossible to version control. Terraform was created to solve this by allowing you to manage infrastructure programmatically.

The mental model

Terraform is like a general contractor for your cloud infrastructure. You give it a blueprint (a configuration file) describing the final state you want: "I need two web servers, a database, and a load balancer." Terraform then figures out the exact steps to build, modify, or demolish resources to make reality match the blueprint. It uses specific plugins called "providers" to talk to each service's API, whether it's AWS, GCP, or even a DNS service.

How it works

You write your desired infrastructure in a human-readable language called HCL (HashiCorp Configuration Language). The workflow has three main steps. First, terraform init prepares your project and downloads the necessary providers. Second, terraform plan shows you a dry run of exactly what will be created, changed, or destroyed. Finally, terraform apply executes that plan. Terraform records what it built in a special "state file" to keep track of your infrastructure.

When to use it

Use Terraform to manage any resource that has an API. It's most common for provisioning low-level cloud components like compute instances, storage, and networking on AWS, Azure, and GCP. It's also great for higher-level components like DNS entries, SaaS features, or even creating GitHub repositories. Its main strength is creating identical, reproducible environments for development, staging, and production.

When not to use it

Terraform is not a configuration management tool like Ansible or Puppet. Terraform is excellent at provisioning a server, but it's not the right tool for installing software or managing files inside that server once it's running. While you can force it to run scripts on startup, dedicated tools are better suited for configuring the software layer.

One canonical example

A classic use case is deploying a web application. A Terraform configuration would define a VPC (a private network), subnets, security groups (firewall rules), a virtual server to run the application, a managed database for data storage, and a load balancer to distribute traffic. With a single terraform apply command, this entire stack is provisioned in the correct dependency order.

Interview question

Which task is Terraform NOT primarily designed to handle?

  • a.Generating a dry run preview of infrastructure changes before applying them
  • b.Orchestrating the deployment of an entire web application stack
  • c.Installing and configuring software packages inside a provisioned serverCorrect
  • d.Defining the network topology for a cloud environment
Why?

Terraform is an Infrastructure as Code tool focused on provisioning and managing infrastructure resources. It is explicitly stated that Terraform is not a configuration management tool for installing software or managing files inside a server once it's running.

Just read this? Test yourself on what you have been reading.

Read the original → developer.hashicorp.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on iac — each one lists the topics its interview covers.

See open roles