TF-004 Understand Terraform basics Practice Question
What file extension is commonly used for Terraform configuration files?
⚠ Common exam trap
Candidates often confuse the `.tf` extension (configuration) with the `.tfstate` extension (state file).
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
✓
.tf
Terraform uses HashiCorp Configuration Language (HCL) for its configuration files, and the standard file extension for these files is `.tf`. Terraform automatically loads all files ending in `.tf` in a directory as part of its configuration, making `.tf` the primary and required extension for Terraform configuration.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
.json
Why it's wrong here
While Terraform does support defining configurations in JSON format, particularly useful for machine generation or programmatic tooling integrations, it is not the commonly used or idiomatic file extension for human-authored Terraform configuration files. The HashiCorp Configuration Language (HCL) is specifically designed for readability and conciseness, making it the preferred syntax for direct human interaction, typically residing in `.tf` files. JSON configurations are generally more verbose and less ergonomic for manual authoring.
- ✗
.hcl
Why it's wrong here
HCL stands for HashiCorp Configuration Language, which is the declarative language Terraform uses to define infrastructure. While the language itself is HCL, the standard and expected file extension for Terraform configuration files written in HCL is `.tf`, not `.hcl`. The `.hcl` extension is occasionally used for generic HCL files unrelated to Terraform, but it is not the convention for Terraform configuration, which relies on the `.tf` extension for automatic discovery.
- ✗
.tfstate
Why it's wrong here
The `.tfstate` file extension is exclusively reserved for Terraform state files, which are crucial for tracking the real-world infrastructure managed by Terraform. This file contains a comprehensive mapping of resources defined in your configuration to their actual provisioned counterparts, including their attributes and metadata. It is fundamentally distinct from configuration files, which *define* the desired state, as the state file records the *current* observed state of your infrastructure.
- ✗
.yaml
Why it's wrong here
YAML (YAML Ain't Markup Language) is a widely adopted data serialization format frequently used for configuration in many other software tools and systems, notably within the cloud-native ecosystem. However, Terraform does not natively support YAML for defining its infrastructure configurations. Terraform strictly relies on its proprietary HashiCorp Configuration Language (HCL) or, as an alternative, its JSON equivalent for all infrastructure definitions, provider configurations, and variable declarations.
- ✓
.tf
Why this is correct
The `.tf` file extension is the universally recognized and standard convention for Terraform configuration files. These files contain infrastructure definitions written in HashiCorp Configuration Language (HCL), specifying resources, data sources, variables, outputs, and providers. Terraform automatically loads and processes all `.tf` files found within a given directory as a single, cohesive configuration, making this extension essential for project organization and execution.
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.