Terraform

Infrastructure as code tool that enables safe, efficient provisioning and management of infrastructure across cloud providers using declarative configuration.

What is Terraform?

Terraform is an open-source Infrastructure as Code (IaC) tool created by HashiCorp that allows you to define, provision, and manage infrastructure using human-readable configuration files. It supports multiple cloud providers including AWS, Google Cloud, Azure, and many others, enabling a unified approach to infrastructure management across different platforms.

Key Components

Typical Use Cases

Mental Model

Think of Terraform as a blueprint language for infrastructure. You describe what you want ("I want 3 servers, a database, a load balancer"), and Terraform figures out how to build it and keep it in sync. Change your blueprint, and Terraform intelligently updates only what changed.

Architecture Overview


[HCL Configuration Files]
    ↓
[Terraform CLI]
  ├─ Parse Configuration
  ├─ Plan Changes (terraform plan)
  └─ Apply Changes (terraform apply)
    ↓
[Terraform State File]
    ↓
[Provider Plugins] ← → [Cloud APIs]
  ├─ AWS Provider
  ├─ GCP Provider
  └─ Azure Provider
    ↓
[Cloud Resources]
      

Terraform reads HCL configs, consults state to detect changes, and communicates with cloud provider APIs through plugins. The state file ensures idempotency—running apply twice produces the same result.

Key Concepts Glossary

When to Use Terraform

Choose Terraform if you need:

Consider alternatives if:

Getting Started

Download and install Terraform, then initialize a project:

terraform version
cd my-infrastructure && terraform init

→ Terraform Documentation

Resources for Further Learning