Skip to main content

Introduction to Terraform

Imagine you’re building infrastructure on AWS. You could use CloudFormation, but it only works for AWS. If tomorrow your company wants to expand to Azure or GCP, you’d need to learn their tools too. That means vendor lock‑in and duplicated effort.

Terraform solves this problem by being cloud‑agnostic.

  • One tool, one language, multiple clouds.
  • Whether it’s AWS, Azure, GCP, or even Kubernetes clusters, Terraform speaks to all of them.
  • It’s like having a universal remote control for your entire cloud ecosystem.

What is Terraform?

Terraform is an open-source Infrastructure as Code (IaC) tool created by HashiCorp that lets you define, provision, and manage cloud and on-premises resources using code.

It uses a declarative language called HCL (HashiCorp Configuration Language) to describe the desired state of infrastructure, and then automatically builds it across providers like AWS, Azure, Google Cloud, and more.


Declarative Simplicity

Terraform uses a declarative approach: you describe the desired state, and Terraform figures out the steps.

  • Example: “I want 3 EC2 instances in this subnet.”
  • Terraform checks what exists, creates what’s missing, and ensures the final state matches your blueprint.
    This makes infra predictable and reduces human error.

Advantages of Terraform

  • Multi‑Cloud Support: Works across AWS, Azure, GCP, and more.
  • Strong Community: Thousands of modules available in the Terraform Registry.
  • Modularity: Reusable modules for scalable infra.
  • State Management: Tracks infra changes for consistency.
  • Integration: Works seamlessly with CI/CD pipelines.
  • Open Source: Free to use, with enterprise features available.

The Real‑World Story

A fintech company wants to deploy workloads across AWS (for compute) and GCP (for analytics).

  • Without Terraform: Two separate teams, two separate tools, double the effort.
  • With Terraform: One team, one tool, one workflow.
Result: Faster deployments, unified infra management, reduced costs.

CloudFormation vs Terraform

Terraform Config (Cloud‑agnostic):

provider "aws" {
  region = "us-east-1"
}

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}

CloudFormation Template (AWS‑specific):

Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t2.micro
      ImageId: ami-0c55b159cbfafe1f0
Notice: Terraform syntax is simpler, reusable, and can extend to other providers.

Summary & Cheatsheet

  • Terraform = Cloud‑agnostic IaC tool.
  • Why Terraform? Multi‑cloud support, declarative syntax, modular design, strong community.
  • Comparison: CloudFormation = AWS‑only; Terraform = universal.
  • Benefits: Portability, predictability, scalability, collaboration.
Quick mnemonic: Terraform = One Language, Many Clouds

The Hackers Notebook

In short, Terraform is like a blueprint for your digital infrastructure - you write the plan once, and Terraform ensures it’s built exactly as described, every time.


Tips, Tricks, Roadmaps, Resources, Networking, Motivation, Guidance, and Cool Stuff ♥

Updated on Dec 31, 2025