Courseiva
Understand Terraform's purposemediumMultiple ChoiceObjective-mapped

TF-004 Understand Terraform's purpose Practice Question

A company wants to ensure that Terraform configurations are consistent across teams. What practice should they adopt?

⚠ Common exam trap

A common mistake is assuming a single file ensures consistency, but modules from a registry provide version-controlled, shareable configurations that standardize infrastructure across teams.

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

Use modules from a registry

Using modules from a registry (Option B) is the correct practice because modules encapsulate reusable, version-controlled infrastructure configurations that enforce consistency across teams. By referencing a shared registry, teams can standardize on approved module versions, reducing drift and ensuring compliance with organizational policies. This approach aligns with Terraform's best practices for code reuse and collaboration.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Write all code in a single file

    Why it's wrong here

    Writing all Terraform code in a single, monolithic file severely hinders maintainability and consistency, especially as infrastructure grows in complexity. This approach prevents the logical separation of resources, making it difficult to understand dependencies, debug issues, and apply changes consistently across different environments or projects. It eliminates the benefits of modularity, making code reuse impossible and significantly increasing the risk of configuration drift due to manual modifications.

  • Use modules from a registry

    Why this is correct

    Using modules from a registry is the most effective method to ensure consistent Terraform configurations across an organization. Modules encapsulate a set of related infrastructure resources, allowing them to be defined once with standardized inputs and outputs, then reused across multiple projects or environments. This promotes consistency by enforcing predefined patterns, reducing configuration drift, and enabling centralized management and versioning of infrastructure components, directly addressing the need for reliable and repeatable deployments.

  • Use provisioners extensively

    Why it's wrong here

    Extensive use of provisioners, which execute scripts on a local or remote machine after a resource has been created, introduces imperative logic that Terraform cannot manage declaratively. While useful for specific bootstrapping or cleanup tasks, relying heavily on provisioners makes configurations less predictable and harder to audit, as the desired state is not fully defined within Terraform itself. This approach significantly undermines consistency by introducing external, ad-hoc scripting, increasing the risk of configuration drift and operational complexity.

  • Avoid using variables

    Why it's wrong here

    Avoiding variables forces the hardcoding of values directly into Terraform configurations, which severely limits flexibility and reusability across different environments. Without variables, adapting configurations for distinct contexts (e.g., development, staging, production) would necessitate duplicating and manually modifying entire codebases, inevitably leading to inconsistencies and significant maintenance overhead. Variables are crucial for parameterizing configurations, allowing the same code to be applied consistently across various contexts by simply changing input values, thereby promoting the DRY (Don't Repeat Yourself) principle.

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 →

How Courseiva writes practice questions · Editorial policy

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.