TF-004 Read, generate and modify configuration Practice Question
Which command displays the output values defined in the configuration after apply?
⚠ Common exam trap
A common trap is confusing `terraform output` (which shows only declared output values) with `terraform show` (which displays the entire state including all resource attributes). Candidates often choose `terraform show` when they only need to see the defined outputs.
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 is specifically designed to display the output values defined in the configuration after an apply. These outputs are declared in the `output` blocks of the root module and are stored in the state file; running `terraform output` retrieves and prints them in a human-readable format, optionally with `-json` for machine parsing.
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 state
Why it's wrong here
The `terraform state` command is primarily used for advanced state management operations, such as moving, renaming, or removing resources from the Terraform state file. It allows direct manipulation of the state, which is crucial for resolving inconsistencies or importing existing infrastructure. However, it does not provide a direct, user-friendly interface to simply display the output values defined in the configuration, as its focus is on the underlying state structure rather than the high-level outputs.
- ✓
terraform output
Why this is correct
The `terraform output` command is the dedicated utility for retrieving and displaying the values defined in `output` blocks within your Terraform configuration. After a successful `terraform apply`, these output values are computed and stored in the Terraform state file, making them accessible for inspection or use by other scripts and systems. This command can display all defined outputs or a specific named output, providing crucial information about the deployed infrastructure, such as IP addresses or connection strings.
- ✗
terraform plan
Why it's wrong here
The `terraform plan` command generates an execution plan, detailing the actions Terraform will take to achieve the desired state defined in your configuration files. It performs a dry run, showing which resources will be created, updated, or destroyed, without actually making any changes to your infrastructure. While it provides a preview of potential changes, it does not display the final output values, as those are only computed and stored in the state *after* a successful `terraform apply`.
- ✗
terraform show
Why it's wrong here
The `terraform show` command is used to display the current state of a Terraform configuration or a saved plan file in a human-readable format. When used with the state file, it presents a comprehensive view of all managed resources, their attributes, and their associated output values. While outputs are included as part of the entire state representation, `terraform show` is not specifically designed to filter and present *only* the output values, making `terraform output` the more precise tool for that specific task.
Go deeper
Related to this question
About these practice questions
Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.