Back to devops
devops#terraform#iac#devops

Terraform for Absolute Beginners

Infrastructure as Code explained with tiny examples — write .tf files, run three commands, watch cloud resources appear.

Jane Contributor August 2, 2026 10 views

Terraform for Absolute Beginners

Terraform lets you describe cloud resources (servers, databases, buckets) in a text file and create them with one command. This is called Infrastructure as Code (IaC).

Why bother?

  • Reproducible — the same file creates the same infra everywhere.
  • Reviewable — infra changes go through a pull request like code.
  • Auditable — you can see who changed what and when.

A working example

main.tf:

terraform {
  required_providers {
    aws = { source = "hashicorp/aws", version = "~> 5.0" }
  }
}

provider "aws" {
  region = "ap-south-1"
}

resource "aws_s3_bucket" "notes" {
  bucket = "technoteshub-demo-${random_id.suffix.hex}"
}

resource "random_id" "suffix" {
  byte_length = 4
}

output "bucket_name" {
  value = aws_s3_bucket.notes.id
}

The three commands

terraform init      # download the provider (once)
terraform plan      # preview what will change
terraform apply     # actually create the resources
terraform destroy   # remove them when done

The five words

WordMeaning
ProviderA plugin that talks to a cloud (AWS, Azure, GCP…).
ResourceA thing to create (a bucket, a VM, a DNS record).
StateA file Terraform keeps to remember what it created.
VariableAn input you can change without editing the file.
OutputA value Terraform prints after apply (an IP, a URL…).

Beginner tips

  • Never commit terraform.tfstate to git — it may contain secrets. Store it in a remote backend (S3 + DynamoDB lock).
  • Always run terraform plan first. Never blind-apply in production.
  • Use variables.tf for anything that differs between environments.

Real-world example

At a startup, one Terraform repo can create the entire staging environment (VPC, subnets, EKS cluster, RDS, S3, IAM) in ~15 minutes. Later, terraform destroy wipes the demo cluster to save costs overnight.

Keep reading

You may also like

Discussion (0)

No comments yet. Be the first to weigh in.

Leave a comment

Comments are reviewed before appearing.