Terraform, HCL, IaC

00 — What is Terraform

00 — What is Terraform

Terraform is an Infrastructure as Code (IaC) tool. Instead of clicking through the AWS console to create a server, a bucket, or a database by hand, I describe what I want in a text file, and Terraform figures out what to actually create, change, or destroy on the real cloud to match it.

Why this over clicking in a console

Manual console changes leave no record of why something exists, and they're not repeatable — if I need the same setup in a second environment, I have to remember and redo every click. A .tf file is checked into git like any other code: reviewable, repeatable, and it's the one place that says what the infrastructure is actually supposed to look like.

The core building blocks

The three-command workflow

Three files, three very different jobs

FileWhat it isGoes in git?
main.tfthe code — what I want to existyes
.terraform.lock.hclthe exact provider version Terraform locked inyes
terraform.tfstateTerraform's live record of what's actually been created on AWSno

.tfstate never goes in git — it changes on every apply, and it can hold sensitive values. On a real team, this file lives in a shared remote backend (commonly an S3 bucket plus a DynamoDB table for locking) instead of on one person's laptop, so everyone's Terraform is working from the same source of truth and two people can't corrupt it by applying at the same time. Covered in more depth once the exercises reach that point.

id vs arn

Both only become known after a resource is created: