What is Terraform?

· Category: DevOps & CI/CD

Short answer

Terraform is an open-source Infrastructure as Code tool that allows you to define, provision, and manage infrastructure using a declarative configuration language.

How it works

You write configuration files in HCL. Terraform creates an execution plan showing what it will create, modify, or destroy. It then applies the plan and tracks the state of your infrastructure.

Example

resource "aws_instance" "web" {
  ami           = "ami-12345678"
  instance_type = "t3.micro"
  tags = {
    Name = "web-server"
  }
}

Why it matters

Terraform provides a consistent workflow for infrastructure changes. It supports multiple providers, enabling multi-cloud and hybrid cloud strategies.

Tips

  • Use terraform plan before every apply.
  • Store state remotely with locking.
  • Version control your configurations.

Common issues

  • State conflicts occur without remote backends.
  • Drift happens when manual changes are made outside Terraform.
  • Provider upgrades can introduce breaking changes.