18. Command cheat sheet
One-liner. The ten commands that cover 90% of the job.
Memorize
terraform init -upgrade # install/upgrade providers, configure backend
terraform fmt -recursive # canonical formatting
terraform validate # syntax + types, no API calls
terraform plan -out=tfplan # preview, save for apply
terraform apply tfplan # apply exactly what was reviewed
terraform plan -detailed-exitcode # 2 = drift (CI check)
terraform state list # what is managed
terraform import aws_s3_bucket.b my-bucket
terraform output -json # consume from other tools
terraform destroy # ⚠ deletes everything managed
-target=for emergencies only; it leaves the rest unrefreshed.TF_LOG=DEBUGwhen a provider call fails mysteriously.terraform consolefor expression experiments (cidrsubnet,merge).
Trap. terraform destroy on the wrong workspace — verify terraform workspace show and the state key first. Pick it when. always.