Chapter 2 of 520% of exam

The Core Terraform Workflow and CLI

This chapter walks through the day-to-day Terraform workflow of init, plan, and apply, plus the supporting commands for validating, formatting, and destroying infrastructure. Mastering these commands and their order is essential for both the exam and real work.

init, plan, apply

The core loop is write, plan, apply. terraform init prepares the working directory by downloading providers and configuring the backend. terraform plan produces an execution plan previewing changes. terraform apply carries out those changes after confirmation. init must run first because plan and apply depend on installed providers and backend setup.

Previewing and reviewing changes

Running plan before apply lets you review exactly what will be created, changed, or destroyed, reducing the risk of surprises. You can save a plan to a file and apply that exact plan later. This review step is a central safety practice in the Terraform workflow.

Supporting commands

terraform validate checks syntax and internal consistency locally without contacting providers. terraform fmt rewrites files to canonical style for readability. terraform destroy deprovisions everything in the current state after confirmation. Knowing which command has side effects and which is purely local prevents mistakes.

Report