Terraform cheat sheet: plan, apply and state
The command sequence
| Command | Purpose | Boundary |
|---|---|---|
terraform init |
Initialize the directory and selected backend and providers | Initialization is not a deployment |
terraform fmt |
Format configuration | Formatting does not validate provider behavior |
terraform validate |
Check configuration consistency | It does not compare live infrastructure |
terraform plan |
Preview proposed changes | It does not create or update objects |
terraform plan -out=review.tfplan |
Save a plan for review and later application | Treat the file as sensitive; it can contain cleartext values |
terraform apply review.tfplan |
Apply the saved plan | Recheck its scope, state and approval before applying |
terraform state list |
List managed resource addresses | An address is not an availability check |
A replacement review
Suppose a fictional service changes its region. The provider can require replacing the instance instead of updating it. Inspect the plan action and the changed attributes. A successful validate cannot tell you whether replacing that service will interrupt users.
The official plan reference explains normal and refresh-only planning. In this browser course, the simulated provider has a stated schema; real providers decide which arguments force replacement. Practice resource changes and state inspection next.