Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

9.2. Quick Reference

Command cheat sheet:
CommandJobChanges real infra?Notes
initSet up backend, providers, modulesNoRequired first; writes lock file
fmtCanonical formattingNo-check for CI; style only
validateSyntax + internal consistencyNoNeeds init; no credentials
planPreview diffNo-out saves; refreshes state
applyEnact changesYesUpdates state; prompts unless -auto-approve or saved plan
destroyTear down managed resourcesYesReverse-dependency order; scoped to state
importBring resource into stateNo (record)Classic = state only, no config
state list/showInspect stateNoRead-only
state mv/rmEdit state recordNorm ≠ destroy
force-unlockRelease stuck lockNoUse only when sure
"Which feature?" decision aid:
High-yield facts to memorize:
  • ~> 1.2 allows 1.x ≥ 1.2 (not 2.0); ~> 1.2.3 allows only 1.2.x patches.
  • sensitive hides display only — secrets still sit in state in plaintext.
  • Variable precedence (high→low): command line -var/-var-file*.auto.tfvarsterraform.tfvarsTF_VAR_ env vars.
  • plan symbols: + create, - destroy, ~ update in place, -/+ replace.
  • Applying a saved plan skips the approval prompt.
  • version argument works only for registry modules; Git uses ?ref=.
  • Local module sources must start with ./ or ../.
  • Locking is automatic on supporting backends; S3 commonly pairs with DynamoDB; HCP Terraform locks for you.
  • moved/removed and refresh-only are all state-only — they don't change real infrastructure.
  • Sentinel/OPA policy enforcement is an HCP/Enterprise feature; hard-mandatory can't be overridden.
Alvin Varughese
Written byAlvin Varughese
Founder18 professional certifications