Courseiva
Understand Terraform basicsmediumMultiple ChoiceObjective-mapped

TF-004 Understand Terraform basics Practice Question

A team is using Terraform to manage infrastructure across multiple environments (dev, test, prod). They want to reuse the same configuration but vary resource configurations like instance size and number of instances. Which Terraform feature should they 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 modules with variables

Terraform modules with variables allow you to define reusable infrastructure and pass environment-specific variable values. This is the recommended approach for code reuse across environments.

Answer analysis

Option-by-option breakdown

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

  • Separate directories with symlinks

    Why it's wrong here

    Relying on separate directories linked by symlinks for managing infrastructure across multiple environments is an anti-pattern in Infrastructure as Code. This approach introduces significant complexity in version control, makes tracking changes difficult, and can lead to broken references or unexpected behavior, particularly within automated CI/CD pipelines. It fundamentally undermines the benefits of declarative configuration management by creating fragile, non-portable configurations that are hard to maintain and scale.

  • Remote backends with different state files

    Why it's wrong here

    While using remote backends with different state files effectively isolates the state for distinct environments, this approach does not inherently facilitate the reuse of the underlying Terraform configuration. Each separate state file, even if managed by a different backend, still requires its own complete set of .tf files to define the infrastructure. This leads to extensive code duplication across environments, making updates and consistency checks cumbersome and error-prone, rather than promoting a single, reusable configuration.

  • Terraform modules with variables

    Why this is correct

    Terraform modules with variables are the correct and recommended pattern for managing infrastructure across multiple environments or teams. Modules encapsulate a set of related resources into a reusable component, which can then be instantiated multiple times. By passing different variable values to the module for each environment (e.g., `dev`, `staging`, `prod`), teams can deploy identical infrastructure patterns with environment-specific configurations, promoting consistency, reducing code duplication, and simplifying maintenance.

  • Terraform workspaces

    Why it's wrong here

    Terraform workspaces are primarily designed for isolating state within a single, consistent configuration, typically for temporary or feature-branch deployments, rather than managing fundamentally different resource configurations for distinct environments. While workspaces allow for separate state files, they share the exact same configuration files, making it challenging to introduce significant, environment-specific resource variations without resorting to complex and unmanageable conditional logic based on `terraform.workspace`. This limits their utility for robust environment differentiation.

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.