Language

HCL & Core Workflow · Lesson 8 of 30

init, plan, apply

Source: doonops-curriculum/hcl-core--workflow-init-plan-apply.md

Doonops lesson

Goal

Master the 3 commands you will use every day: init, plan, apply.

Simple explanation

init = download tools. plan = rehearsal (what will change). apply = actually do it.

Technical view

init installs providers/backends; plan builds graph and diff; apply executes API calls; destroy removes resources.

Think of it like

init = buy ingredients. plan = read recipe aloud to family. apply = cook. destroy = clean kitchen after party.

Steps

  1. Read simple section
  2. Read analogy + diagram
  3. Copy project files
  4. Do local lab

Deep explanation

Layman words first, then technical detail — read slowly

Command flow (diagram)

Write .tf files
      ↓
 terraform init     ← first time / after new provider
      ↓
 terraform plan     ← ALWAYS read this ( + create, ~ change, - destroy )
      ↓
 terraform apply    ← type yes (or -auto-approve only in labs)
      ↓
 terraform destroy  ← when lab finished (save money)

Symbols in plan output

  • + green — will create new
  • ~ yellow — will change
  • - red — will destroy

Beginners skip plan and get surprises. Treat plan like checking your exam answer sheet before submit.

Example (Doonops)

Modern HCL — names are examples, not from any third-party course

Example HCL
HCL
# terraform init
# terraform plan
# terraform apply
# terraform destroy

Terraform runs on your computer — copy this HCL into a folder, then follow the local lab steps below.

Check

  • Order init/plan/apply
  • What + means in plan

Project files for this lab

Full implementation folder — copy all files, then run terraform commands

Lab project files (full folder)

Copy every file below into one folder — same as a real repo module. Then run the local lab steps.

Suggested folder: Suggested path: ~/doonops-terraform/05-workflow/

versions.tfSee file purpose in the code below
terraform {
  required_version = ">= 1.9.0"
}

Module check — did you get it?

2–3 quick questions before the next module

HCL & workflow — quick check

Quick check — did this module stick?

1. Which command shows changes BEFORE applying?

  • terraform destroy
  • terraform plan
  • terraform fmt
  • git status

2. First command in a new Terraform folder?

  • terraform apply
  • terraform init
  • terraform destroy
  • aws configure