Terraform for Absolute Beginners
Infrastructure as Code explained with tiny examples — write .tf files, run three commands, watch cloud resources appear.
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
| Word | Meaning |
|---|---|
| Provider | A plugin that talks to a cloud (AWS, Azure, GCP…). |
| Resource | A thing to create (a bucket, a VM, a DNS record). |
| State | A file Terraform keeps to remember what it created. |
| Variable | An input you can change without editing the file. |
| Output | A value Terraform prints after apply (an IP, a URL…). |
Beginner tips
- Never commit
terraform.tfstateto git — it may contain secrets. Store it in a remote backend (S3 + DynamoDB lock). - Always run
terraform planfirst. Never blind-apply in production. - Use
variables.tffor 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
devops
Git Handbook – Quick Reference
A complete collection of Git commands and notes, covering setup, commits, branching, merging, conflicts, and advanced workflows. This handbook is designed as a simple, step‑by‑step guide for beginners and professionals to quickly learn and apply Git in real projects.
devops
Kubernetes Explained for Absolute Beginners
The clearest possible introduction to Kubernetes — what it is, why it exists, and the seven words you need to know.
devops
GitHub Actions: A Complete CI Pipeline
Lint, test, build, publish — a battle-tested workflow template.
Discussion (0)
No comments yet. Be the first to weigh in.