Terraform with AWS- Day1: Why Terraform Matters & How It Really Works

Published: (December 18, 2025 at 02:41 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

What Is Infrastructure as Code (IaC)?

Infrastructure as Code (IaC) means you write code to create and manage your cloud infrastructure.
It lets you use code instead of clicking buttons in the cloud console.

Example

resource "aws_instance" "demo" {
  ami           = "ami-12345"
  instance_type = "t2.micro"
}

Benefits of IaC

  • Repeatable
  • Consistent
  • Version‑controlled
  • Automated
  • Error‑free
  • Team‑friendly

Tools Used for IaC

Multi‑Cloud Tools

  • Terraform ⭐ (most popular)
  • Pulumi

Cloud‑Specific Tools

  • AWS CloudFormation, CDK, SAM
  • Azure ARM, Bicep
  • GCP Deployment Manager

Terraform is universal—it works with AWS, Azure, GCP, Kubernetes, and dozens of other platforms. That’s why almost every DevOps roadmap begins with Terraform.

Why Do We Even Need Terraform?

Manual Infrastructure Doesn’t Scale

Consider a simple 3‑tier application (web, app, database). Deploying it manually requires creating:

  • VPC
  • Subnets
  • EC2 instances
  • Auto Scaling Groups
  • Load Balancers
  • RDS Database
  • Route 53 records
  • Security groups
  • …and more

Doing this manually takes roughly 2 hours per environment. Multiply that by typical environments (dev, staging, prod) → 12 hours per app. In real companies, dozens or hundreds of applications need provisioning, leading to:

  • Time‑consuming work
  • High cost
  • Error‑prone processes
  • Inconsistent environments
  • No audit trail

Challenges of Manual Cloud Provisioning

  • Too slow → delayed releases
  • Too many people required → large infra team cost
  • Human errors (wrong AMI, subnet, IP) → outages
  • No consistency (Dev ≠ Staging ≠ Prod) → “It works on my machine!”
  • No version control → no history, audit, or rollback

Terraform: The Ultimate Solution

  • Write infrastructure code once
  • Reuse it for any number of environments
  • Keep everything consistent
  • Automate deployments
  • Eliminate human errors
  • Track all changes through Git
  • Destroy environments automatically to save cost

All of this is achieved with just a few .tf files, bringing speed, safety, repeatability, and control to cloud infrastructure.

How Terraform Actually Works

Terraform uses a declarative language called HCL (HashiCorp Configuration Language). You describe the desired state in .tf files.

Example

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

Core Commands

  • terraform init – downloads provider plugins (always the first command).
  • terraform validate – checks that your Terraform files are syntactically correct.
  • terraform plan – shows a preview of what Terraform will create, modify, or delete (a safety check).
  • terraform apply – actually creates the infrastructure in AWS via API calls.
  • terraform destroy – removes everything defined in your .tf files; useful for dev/testing environments.

Terraform + Git = Pure Magic

Using Git with Terraform provides:

  • Full version history
  • Easy rollbacks
  • Pull‑request approvals
  • Collaboration across teams
  • Faster approval processes
  • CI/CD automation

Infrastructure becomes predictable, secure, and auditable.

Installing Terraform (Quick Summary)

  • Install via Homebrew, apt, yum, or Chocolatey.
  • Verify installation: terraform version
  • Install the VS Code extension HashiCorp Terraform.
  • (Optional) Set an alias: alias tf=terraform for easier typing.

You’re ready to start building infrastructure as code!

Back to Blog

Related posts

Read more »

AWS Terraform Lifecycle Rules

Introduction Infrastructure as Code IaC is most powerful when you have full control over how resources behave during updates, replacements, and deletions. Terr...