Tuesday, 2 September 2025

Getting Started with Terraform: Infrastructure as Code Made Simple (Part 1)

Standard

Have you ever spent hours setting up servers, networks, or databases by clicking through endless dashboards, only to realize you have to repeat it all when something breaks?

This is where Infrastructure as Code (IaC) comes to the rescue and Terraform is one of the best tools out there to make it happen.

In this blog, we’ll cover:

  • What Terraform is
  • Why companies love it
  • How it works under the hood
  • A simple “Hello World” example to get started

What is Infrastructure as Code (IaC)?

Think of IaC as writing recipes for your infrastructure.
Instead of manually creating resources in AWS, Azure, or GCP, you write a configuration file describing what you need: servers, storage, security rules & everything.

Just like software code, this file can be:

  • Version controlled in GitHub
  • Reviewed by teammates
  • Reused across projects

With IaC, your infrastructure setup becomes:

  • RepeatableSpin up identical environments with one command.
  • AutomatedReduce human errors from manual setups.
  • Documented – Your code is the documentation.

Why Terraform?

There are other IaC tools like AWS CloudFormation, Azure Resource Manager, or Ansible.
So why is Terraform such a big deal?

1. Multi-Cloud Support

Terraform works with AWS, Azure, GCP, Kubernetes, GitHub, Datadog… even DNS providers.
One tool, many platforms.

2. Declarative Syntax

You tell Terraform what you want, not how to do it.
For example:

"I want 1 S3 bucket."
Terraform figures out all the API calls for you.

3. State Management

Terraform keeps track of what exists in your cloud so it knows exactly what to change next time.

How Terraform Works (The Big Picture)

Terraform has a simple workflow:

Write → Plan → Apply

  • Write: You write a configuration file in HCL (HashiCorp Configuration Language).
  • Plan: Terraform shows what changes it will make (add, modify, delete).
  • Apply: Terraform executes the plan and talks to the cloud provider APIs.


Case Study: A Startup Saves Time with Terraform

Imagine a small startup launching a new app.

  • They need servers, databases, and storage on AWS.
  • Their developer sets everything manually using the AWS Consol
  • A month later, they want the same setup for testing.
Manually? Again?

Instead, they switch to Terraform:

  • Create one Terraform script for the whole infrastructure.
  • Reuse it for dev, staging, and production.
  • Launch new environments in minutes, not hours.

That’s real-world productivity.

Installing Terraform

Step 1: Download

Go to terraform.io and download for Windows, macOS, or Linux.

Step 2: Verify

Open a terminal and type:

terraform -version

You should see something like:

Terraform v1.8.0

Your First Terraform Project: Hello World

Let’s create a simple AWS S3 bucket using Terraform.

main.tf

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

resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-terraform-hello-world-bucket"
  acl    = "private"
}

Commands to Run

terraform init      # Initialize Terraform project
terraform plan      # See what will be created
terraform apply     # Actually create the bucket

In a few seconds, you have a working S3 bucket.
No clicking through AWS Console.

Case Study: Enterprise-Level Use

At companies like Uber and Airbnb, Terraform manages thousands of servers.

  • Developers write Terraform scripts.
  • Changes go through GitHub pull requests.
  • Once approved, Terraform automatically updates infrastructure.

Result?
Consistency across teams, fewer mistakes, and faster deployments.

Key Takeaways

  • Terraform = Infrastructure automation made simple.
  • It’s cloud-agnostic, declarative, and scalable.
  • Perfect for both startups and enterprises.

What’s Next?

In the next blog, we’ll go hands-on:

  • Create multiple resources
  • Understand state files
  • See how Terraform knows what to create, update, or delete

Bibliography