TF-004 Read, generate and modify configuration Practice Question
A team uses remote state stored in an S3 bucket with DynamoDB locking. A developer wants to read the current state outputs locally without making changes. Which command should they use?
⚠ Common exam trap
The exam often tests the distinction between read-only commands (`terraform output`) and commands that modify or lock state (`terraform state pull`, `terraform plan`), trapping candidates who assume any state-reading command is safe for concurrent use.
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
✓
terraform output
The `terraform output` command retrieves and displays the values of output variables from the current state file. When using remote state with S3 and DynamoDB locking, this command reads the state from the backend without acquiring a lock or modifying the state, making it the safe, read-only option for viewing outputs.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
terraform output
Why this is correct
terraform output is the most appropriate command for retrieving the values of defined outputs from a Terraform state file, including remote state. This command specifically queries the state for output values without requiring a state lock, making it efficient for read-only access. It is ideal when a team needs to quickly access specific resource attributes or computed values exposed as outputs by the configuration, without modifying the infrastructure or acquiring exclusive access to the state.
- ✗
terraform state pull
Why it's wrong here
terraform state pull downloads the entire remote state file to the local machine and prints its JSON content to standard output. While it does provide access to all data within the state, including outputs, its primary purpose is to inspect the full state for debugging or migration, not just specific outputs. Crucially, `terraform state pull` acquires a state lock during execution to prevent concurrent modifications, which is an unnecessary overhead and potential bottleneck when merely trying to retrieve output values.
- ✗
terraform console
Why it's wrong here
terraform console launches an interactive console for evaluating expressions against the current state and configuration. While one *could* manually query `terraform.outputs` within the console to see output values, its primary function is for ad-hoc testing of interpolation syntax and resource attribute lookups, not for programmatic or direct retrieval of defined outputs. It does not directly "output" the values in a machine-readable format suitable for scripting or simple viewing, and it's an interactive shell rather than a direct command for this purpose.
- ✗
terraform plan
Why it's wrong here
terraform plan computes and displays the changes that Terraform plans to make to the infrastructure to reach the desired state. This command acquires a state lock to ensure the plan is based on the most current state and prevents concurrent operations that could invalidate the plan. While a plan output *might* incidentally show some resource attributes that are also defined as outputs if they are part of a planned change, its core purpose is not to list existing outputs, and it's an expensive operation involving a full refresh and comparison, making it unsuitable for simply retrieving output values.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.