Terraform

Terraform

Infrastructure as Code for provisioning cloud resources

Features

  • Declarative infrastructure as code with HCL
  • Multi-cloud support (AWS, GCP, Azure, and more)
  • State management tracks infrastructure changes
  • Plan/apply workflow previews changes before executing

Pros

  • Most widely adopted IaC tool
  • Supports virtually every cloud provider and service
  • Large community with extensive module registry

Cons

  • HCL language has limited programming capabilities
  • State management requires careful handling
  • BSL license change caused community concern

Overview

Terraform is an infrastructure as code (IaC) tool created by HashiCorp. It allows you to define cloud infrastructure in declarative configuration files using HCL (HashiCorp Configuration Language), then provision and manage that infrastructure through a consistent workflow.

Terraform’s plan/apply workflow is central to its design. Running terraform plan shows you exactly what changes will be made to your infrastructure before anything is executed. Running terraform apply then makes those changes. This preview step prevents costly mistakes and enables code review of infrastructure changes.

Terraform maintains a state file that tracks the mapping between your configuration and real-world resources. This state enables it to determine what needs to change when you update your configuration, and to detect drift from the desired state.

When to Use

Choose Terraform for managing cloud infrastructure across one or more providers. It is the standard IaC tool for teams that prefer declarative configuration. For those who prefer using general-purpose programming languages, consider Pulumi.

Getting Started

# main.tf
terraform {
  required_providers {
    aws = { source = "hashicorp/aws" }
  }
}

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.micro"
}
terraform init
terraform plan
terraform apply