Terraform Configuration Generation Methods
Which three of the following are valid methods for reading, generating, or modifying Terraform configuration? (Choose three.)
Quick Answer
The answer is terraform console, terraform fmt, and the templatefile function. These three are valid methods for reading, generating, or modifying Terraform configuration because each serves a distinct purpose in the configuration lifecycle: terraform console provides an interactive shell to evaluate expressions and inspect resource attributes, making it ideal for reading and testing logic; terraform fmt rewrites configuration files into a canonical format, directly modifying their style without altering functionality; and the templatefile function reads an external template file and renders it with supplied variables, enabling dynamic configuration generation. On the HashiCorp Terraform Associate TF-003 exam, this question tests your understanding of the tools and functions that interact with configuration, not just apply infrastructure—a common trap is confusing terraform plan or apply with these read/modify methods. Remember the mnemonic “CFT” for Console, Fmt, Templatefile to recall the three valid approaches.
⚠ Common exam trap
HashiCorp often tests the distinction between state manipulation commands and configuration generation commands, leading candidates to confuse `terraform state push` (a state management operation) with a method to modify configuration, or to incorrectly assume `terraform plan` has a `-generate-config-out` flag when it is actually `terraform import` that supports this feature.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Using the `terraform fmt` command to automatically update configuration files to a canonical format and style.
The `terraform fmt` command rewrites configuration files to a canonical format and style, which is a valid method for modifying configuration. The `templatefile` function reads a template file and renders it with supplied variables, enabling dynamic configuration generation. The `terraform console` command provides an interactive shell for evaluating expressions and inspecting resource attributes, which is a valid way to read and test configuration logic.
Go deeper
Related to this question
About these practice questions
One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on TF-004
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which four of the following are valid techniques for reading, generating, or modifying Terraform configuration? (Choose all that apply. There are four correct answers.)
medium- ✓ .Using a `data` source with a `for_each` and a `local` value to dynamically generate resource blocks based on a variable input.
- ✓ .Using the `templatefile` function to render a template with variables from the current configuration.
- ✓ .Using the `jsonencode` function within a `local` value to programmatically construct a JSON string that is then used as part of a resource argument.
- ✓ .Using `terraform validate` to check configuration syntax and internal consistency before applying changes.
- .Using `terraform console` to evaluate expressions and generate valid HCL configuration output.
- .Using `terraform state pull` to retrieve remote state and then using `terraform state mv` to rename a resource address in the local state file before pushing it back.
Why : The `templatefile` function is a valid technique for reading and generating configuration because it reads an external template file and renders it with variables from the current Terraform configuration, producing a string that can be used in resource arguments or other expressions. This is a core feature for dynamic configuration generation, such as injecting user data into cloud-init scripts or generating complex configuration files for provisioned resources.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.