Terraform Associate Domain 3: Core Terraform Workflow
30 free practice questions for Core Terraform Workflow in the HashiCorp Certified: Terraform Associate (004) exam. Try each question first, then open "Show answer" for the correct option and explanation.
Core Terraform Workflow practice questions
-
Question 1. What is the core Terraform workflow?
Show answer
Answer: B. Write, plan, apply
You write configuration, review the plan, then apply it. init comes first in a new working directory.
-
Question 2. Which command must you run first in a new working directory before plan or apply?
Show answer
Answer: C. terraform init
init prepares the directory so later commands can run.
-
Question 3. What does terraform init do?
Show answer
Answer: A. Installs providers and modules and sets up the backend
It's safe to run init repeatedly; it won't change infrastructure.
-
Question 4. When do you need to run terraform init again in an existing directory?
Show answer
Answer: D. After adding a provider or module, or changing the backend
New providers and modules must be installed, and backend changes must be initialized, before plan works.
-
Question 5. You changed the backend configuration and want to copy the existing state to the new backend. Which command does this?
Show answer
Answer: B. terraform init -migrate-state
-migrate-state copies state to the new backend. -reconfigure ignores the old configuration and doesn't migrate state.
-
Question 6. What does terraform validate check?
Show answer
Answer: A. Syntax and internal consistency, without contacting remote services
It catches errors like wrong argument names or types early. It doesn't check real-world things such as whether a name is already taken.
-
Question 7. Can terraform validate run in a directory that hasn't been initialized?
Show answer
Answer: C. No; init must install providers so it can check resource arguments
validate needs the provider schemas. In CI, terraform init -backend=false is a common way to prepare without touching state.
-
Question 8. What does terraform fmt do?
Show answer
Answer: B. Rewrites configuration files into the standard style
fmt fixes indentation and alignment. Run it before committing so diffs stay clean.
-
Question 9. In CI, which command fails if any file in the directory tree isn't formatted, without changing files?
Show answer
Answer: D. terraform fmt -check -recursive
-check exits non-zero if changes are needed, and -recursive includes subdirectories.
-
Question 10. What does terraform plan do?
Show answer
Answer: A. Compares configuration with state and reality and proposes changes
plan refreshes state, compares it with the configuration, and shows what would be created, updated, replaced, or destroyed.
-
Question 11. Which command saves a plan to a file so the same plan can be applied later?
Show answer
Answer: C. terraform plan -out=tfplan
A saved plan is binary and should be treated as sensitive, since it can contain secret values.
-
Question 12. What happens when you run terraform apply tfplan with a saved plan?
Show answer
Answer: B. It applies exactly the saved plan without asking again
The approval happened when the plan was reviewed. If state changed since, Terraform rejects the stale plan.
-
Question 13. In plan output, what does the symbol -/+ mean for a resource?
Show answer
Answer: D. It will be replaced: destroyed, then created
Replacement happens when a changed argument can't be updated in place. With create_before_destroy, the symbol is +/-.
-
Question 14. A resource in plan output is marked with a tilde (~). What will Terraform do to it?
Show answer
Answer: A. Update it in place
~ marks an in-place update. + means create and - means destroy.
-
Question 15. What happens when you run terraform apply without a saved plan file?
Show answer
Answer: C. It creates a plan, shows it, and asks for confirmation
Type yes to proceed. Anything else cancels.
-
Question 16. Which option makes terraform apply skip the interactive approval?
Show answer
Answer: B. -auto-approve
It's used in automation, ideally only after a reviewed plan, for example by applying a saved plan file.
-
Question 17. Which command destroys all resources managed by the current configuration?
Show answer
Answer: D. terraform destroy
destroy shows a plan of everything to delete and asks for confirmation.
-
Question 18. Which command previews what terraform destroy would remove, without destroying anything?
Show answer
Answer: A. terraform plan -destroy
terraform destroy is an alias for terraform apply -destroy, and plan -destroy shows the same plan without applying.
-
Question 19. A VM is unhealthy, and you want Terraform to recreate just that resource. Which command is recommended?
Show answer
Answer: C. terraform apply -replace=aws_instance.web
-replace plans a replacement in one reviewed step. terraform taint is deprecated in its favour.
-
Question 20. When should you use the -target option?
Show answer
Answer: B. Only in exceptional cases, such as recovering from errors
Targeting applies part of the configuration and can leave the rest out of sync. Splitting large configurations is the better long-term fix.
-
Question 21. How do you set the variable region on the command line?
Show answer
Answer: D. terraform plan -var="region=us-west-2"
-var can be repeated. For many values, use -var-file instead.
-
Question 22. How do you load variable values from prod.tfvars, which isn't loaded automatically?
Show answer
Answer: A. terraform plan -var-file=prod.tfvars
terraform.tfvars and *.auto.tfvars are loaded automatically; other files need -var-file.
-
Question 23. With terraform plan -detailed-exitcode, what does exit code 2 mean?
Show answer
Answer: C. The plan succeeded and changes are present
0 means no changes, 1 means an error, and 2 means changes are pending. CI jobs use it for drift checks.
-
Question 24. Which command shows a saved plan file in a readable form?
Show answer
Answer: B. terraform show tfplan
Add -json for machine-readable output, for example to feed policy tools.
-
Question 25. An apply fails halfway through. What is true of the resources created before the error?
Show answer
Answer: D. They are recorded in state, so fix the error and apply again
Terraform doesn't roll back. The next plan shows only the remaining work.
-
Question 26. What is terraform console for?
Show answer
Answer: A. Trying out expressions and functions interactively
It evaluates expressions against the current configuration and state, which helps when writing for expressions or function calls.
-
Question 27. What does terraform graph output?
Show answer
Answer: C. The dependency graph in DOT format
The DOT output can be rendered with Graphviz to inspect dependencies.
-
Question 28. By default, how many resource operations does Terraform run at the same time?
Show answer
Answer: B. 10
-parallelism=n changes it, for example to stay under an API's rate limits.
-
Question 29. Does terraform destroy delete cloud resources that Terraform doesn't track in its state?
Show answer
Answer: D. No, it only destroys resources recorded in state
Terraform only acts on what it manages. Resources made by hand are untouched.
-
Question 30. You delete a resource block from the configuration and run terraform apply. What does Terraform plan to do?
Show answer
Answer: A. Destroy that resource
The resource is still in state but no longer in configuration, so Terraform plans to destroy it. A removed block can forget it instead.
HashiCorp, Terraform, and HCP Terraform are trademarks of HashiCorp, Inc. These questions are original study material, not questions from the real exam.