TF-004 Use Terraform outside the core workflow Practice Question
A company has a Terraform configuration that creates many AWS resources. They want to check the estimated cost of the plan before applying. Which approach should they use?
⚠ Common exam trap
Terraform often tests the misconception that 'terraform plan' has a built-in cost flag, but no such flag exists in the Terraform CLI; cost estimation is exclusively a Terraform Cloud 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
✓
Enable cost estimation in Terraform Cloud.
Terraform Cloud provides a built-in cost estimation feature that analyzes the resources in a plan against current cloud provider pricing APIs to estimate monthly costs. This is the recommended approach because it is integrated directly into the Terraform workflow and does not require manual parsing or external scripts. Option C is correct because it leverages Terraform Cloud's native capability to estimate costs before applying.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use 'terraform plan -cost' command.
Why it's wrong here
The "terraform plan" command generates an execution plan, detailing resource changes without native cost estimation capabilities. There is no built-in "-cost" flag or subcommand within the Terraform CLI designed to calculate or display monetary costs associated with the planned infrastructure. Cost analysis requires integration with external tools or platforms, as Terraform's primary function is infrastructure provisioning, not financial forecasting.
- ✗
Manually use 'terraform show -json' and parse pricing.
Why it's wrong here
While "terraform show -json" can output the state or plan in a machine-readable format, extracting cost information from this output is a highly manual and complex process. It would require developing custom scripts to parse resource attributes, cross-reference them with cloud provider pricing APIs or databases, and then aggregate the costs. This approach lacks automation, accuracy, and scalability, making it impractical for reliable cost estimation.
- ✓
Enable cost estimation in Terraform Cloud.
Why this is correct
Terraform Cloud offers native cost estimation capabilities, particularly for AWS resources, by integrating directly into the planning workflow. When a "terraform plan" is executed in Terraform Cloud, it analyzes the proposed resource changes against current cloud provider pricing data. This feature provides an estimated monthly cost impact directly within the plan output, offering a streamlined and automated solution for financial oversight.
- ✗
Use 'terraform validate' with a custom script.
Why it's wrong here
The "terraform validate" command is specifically designed to check the syntax and internal consistency of a Terraform configuration, ensuring it is syntactically valid and internally consistent. It does not interact with cloud providers or analyze resource attributes for cost implications. Therefore, attempting to use "terraform validate" with a custom script for cost estimation would fundamentally misuse its intended purpose, as its scope is limited to configuration validation, not financial analysis.
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 →
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.