Terraform 004 cheat sheet: quick reference

Updated November 23, 2026

Last-minute reference for the HashiCorp Terraform Associate (004). It follows HashiCorp’s eight-objective content list, which publishes no weights, so every objective is fair game.

Exam facts

FormatMultiple choice, online proctored
Duration1 hour
QuestionsNot published
Passing scoreNot published
Price$70.50 USD plus local taxes and fees
Validity2 years
Terraform version1.12, plus HCP Terraform
LanguageEnglish
Free retakeNot included

HashiCorp’s sample page shows true or false, multiple choice and multiple answer questions; for multiple answer, the prompt says how many to choose.

Objectives at a glance

#ObjectiveCore idea
1Infrastructure as CodeDeclarative, versioned, repeatable, one workflow across platforms
2FundamentalsProviders are plugins; versions pinned in the lock file; state maps config to real objects
3Core workflowinit, validate, plan, apply, destroy, fmt
4ConfigurationResources, data, variables, types, expressions, dependencies, conditions, sensitive data
5ModulesIsolated; inputs in, outputs out; pin versions
6StateLocal backend, locking, remote backend, drift
7MaintainImport, state commands, TF_LOG
8HCP TerraformWorkspaces, projects, runs, policies, integrations

New in 004 per HashiCorp: 4f dependencies, 4g custom conditions, 4h sensitive data and secrets, 8c workspaces and projects.

Commands

CommandRemember
terraform initDownloads providers and modules, sets up the backend; rerun after adding any of these
terraform validateSyntax and internal consistency only
terraform fmtCanonical style; -check reports without rewriting
terraform planProposes changes; -out saves a plan
terraform applyExecutes; apply a saved plan to run exactly what was reviewed
terraform destroyRemoves what the configuration and state manage; same as apply with the destroy option
apply -replace=ADDRRecreate one resource (use instead of the older taint idea)
plan or apply -refresh-onlyUpdate state to match reality, no infrastructure change
terraform state list / showRead state, change nothing
terraform force-unlock IDRelease a stale lock, only if nothing else is running

Plan symbols: plus creates, minus destroys, tilde updates in place, minus plus together replaces.

Configuration rules

  • resource creates and manages; data only reads.
  • Reference data as data.TYPE.NAME.ATTR, a child module output as module.NAME.OUTPUT.
  • Variable sources, lowest to highest precedence: defaults, TF_VAR_ environment variables, terraform.tfvars, *.auto.tfvars, then -var and -var-file on the command line.
  • for_each takes a map or a set of strings (use toset for a list); count ties instances to index numbers, so removing a middle item shifts the rest.
  • Implicit dependency comes from a reference; depends_on is explicit and only for what no argument expresses.
  • Custom conditions: variable validation for inputs; precondition and postcondition in a resource or data source lifecycle block (postcondition can use self); output precondition.
  • sensitive redacts output only and does not keep values out of state or plan files.
  • Ephemeral values (Terraform 1.10) and write-only arguments (1.11) are not stored in state or plan. HashiCorp’s own page for 4h names Vault-based secrets management, and its list of new topics names ephemeral values and write-only arguments, so know both.

Modules

A module is any folder of .tf files; the directory you run in is the root module. A child cannot read parent variables, locals or resources. The version argument works for registry modules, not for local paths. Pin with ~>: ~> 5.1.0 allows 5.1.x, ~> 5.1 allows up to but not including 6.0. module blocks accept count and for_each.

State and maintenance

  • Default is a local terraform.tfstate; teams use a remote backend through the backend block, and changing it means terraform init and a state migration.
  • Locking prevents concurrent writes where the backend supports it.
  • Drift is real infrastructure differing from state or configuration; plan detects it.
  • Import attaches an existing object to a resource address; an import block makes it reviewable in a plan. You still write the resource configuration.
  • TF_LOG sets the level (TRACE, DEBUG, INFO, WARN, ERROR); TF_LOG_PATH only sets the file and does nothing without TF_LOG.

HCP Terraform

ConceptRemember
OrganizationTop level: teams, projects, registry
ProjectGroups workspaces for access and settings
WorkspaceConfig source, variables, state and run history for one set of infrastructure (not the same as a CLI workspace)
Variable setShares values across workspaces
Run triggerA successful run in one workspace queues a run in another
WorkflowsVersion control driven, CLI driven, API driven
Policy checksRun between plan and apply and can block the run
Dynamic credentialsShort-lived cloud credentials instead of stored keys

Common traps

  1. Believing validate checks real cloud values.
  2. Thinking init is only a once-per-project step.
  3. Assuming sensitive protects state.
  4. Giving a list to for_each without toset.
  5. Putting a version argument on a local module.
  6. Treating a CLI workspace as an HCP Terraform workspace.
  7. Setting TF_LOG_PATH without TF_LOG.
  8. Editing the state file by hand instead of using state commands.

Practise with the 20-question test, then review weak spots in the configuration and state guides.