Let’s Get Certified
Module 04 / 09 · Core workflow

Read the plan and promote the reviewed change

Distinguish formatting, initialization, validation, planning and applying in an isolated working directory.

Read the plan and promote the reviewed change

Initialize the directory after adding dependencies or changing module sources. Format HCL consistently with fmt. Validate after initialization to catch structural or type errors that Terraform can prove without a target run. A valid configuration can still request an unavailable service size or a change that the caller lacks permission to make.

Plan with the target workspace, input values and credentials. Inspect create, update, replace and destroy markers. Save a plan with the output option when the approved change must be carried forward. Protect saved plans because they can contain sensitive values. A stale plan after a separate state change needs a new review. To retire an isolated stack, preview the destroy plan and verify the workspace and every affected object.

Worked case 1

Validation succeeded but the production plan replaces a storage resource. Should the operator proceed on the strength of the validation result?

Check your reasoning

No. Validation checks configuration structure. The plan describes the proposed operations for this target. Explain the replacement, verify data protection and resolve any unintended change before approval.

Worked case 2

A second run modified state after a saved plan was approved. Why should the release owner create another plan?

Check your reasoning

The reviewed proposal was based on an earlier state snapshot. Refresh the evidence in the correct workspace and review the new operations.

Reject an invalid input and inspect a saved plan

Run this block in Bash with Terraform 1.12 and Python 3. It creates a new temporary directory and uses the built-in terraform_data resource. Predict the result of supplying zero replicas.

(
set -eu
cd "$(mktemp -d)"
cat > main.tf <<'HCL'
variable "replicas" {
  type = number
  validation {
    condition     = var.replicas >= 1 && var.replicas == floor(var.replicas)
    error_message = "Supply a positive whole number."
  }
}
resource "terraform_data" "capacity" {
  input = var.replicas
}
HCL
terraform init -input=false >/dev/null
terraform validate >/dev/null
if terraform plan -input=false -var='replicas=0' >rejected.log 2>&1; then
  exit 1
fi
grep -q 'Supply a positive whole number' rejected.log
echo 'Input 0 rejected'
terraform plan -input=false -var='replicas=3' -out=approved >/dev/null
terraform show -json approved | python3 -c 'import json,sys; c=json.load(sys.stdin)["resource_changes"][0]["change"]; print(c["actions"][0], c["after"]["input"])'
)
Check your output
Input 0 rejected
create 3

Validation checks the structure. Planning with real inputs evaluates the supplied value and records the proposed create. No cloud account is used.

HashiCorp objective references: 3a–3g.

Terraform CLI workflow · Official Terraform 004 objectives for this domain

Related lesson in GitHub Actions. Verify authority and provenance before deployment.

Practice with the recording

A pipeline validates configuration on Monday and wants to apply it on Friday. What would let a reviewer approve the actual proposed changes?

Check your reasoning

Generate a plan for the target state and inputs, inspect it and apply the reviewed saved plan when it is still valid. If state changes make that plan stale, generate and review a new one. Formatting and validation alone do not inspect live infrastructure.

sthithapragna · Terraform Associate 004 full course · 1:24:34

Practice the individual exam skills
  • 3a–3g In a disposable workspace, format the file, initialize, validate, save a plan and inspect it before applying. Generate a destroy plan afterwards. For each command identify whether it can change formatting, local metadata, managed state or the remote object.
Knowledge check

Read the plan and promote the reviewed change quiz

Answer 3 questions. Check each answer for an explanation.

Worked example · Saved plan