Courseiva
Understand IaC conceptshardMultiple ChoiceObjective-mapped

TF-004 Understand IaC concepts Practice Question

Exhibit

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
  tags = {
    Name = "WebServer"
  }
}

Refer to the exhibit. After applying this configuration, a team member manually changes the instance type to 't2.small' via the AWS console. The next `terraform plan` shows a change to revert to 't2.micro'. What does this demonstrate?

⚠ Common exam trap

The Terraform exam often tests the distinction between drift detection (passive observation) and desired state reconciliation (active correction). The trap here is that candidates confuse the two, thinking Terraform only reports drift when it actually plans to enforce the declared state.

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's desired state reconciliation

Terraform operates on a desired state model: the configuration file defines the target state (t2.micro), and `terraform plan` detects that the actual state (t2.small) has diverged from it. The plan proposes to revert the instance type to t2.micro, demonstrating Terraform's reconciliation of the actual infrastructure back to the declared desired state. This is not merely drift detection (which only reports differences) but active enforcement of the desired 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.

  • Terraform's drift detection only

    Why it's wrong here

    Terraform's `plan` command is designed to identify differences between the declared configuration and the actual infrastructure state, a process known as drift detection. However, it goes beyond mere detection by also generating an execution plan that proposes specific actions to bring the infrastructure back into alignment with the desired state. Therefore, stating it's 'drift detection only' is inaccurate, as its core function includes proposing corrective measures to resolve the drift.

  • Immutable infrastructure pattern

    Why it's wrong here

    The immutable infrastructure pattern advocates for never modifying existing resources in place once they are deployed. Instead, any configuration change or update necessitates provisioning an entirely new resource with the desired state and then replacing the old one. Since Terraform, in this scenario, is planning to modify the existing resource to revert a manual change, this action directly contradicts the principles of immutable infrastructure.

  • Terraform's desired state reconciliation

    Why this is correct

    Terraform operates on the principle of desired state configuration, where the HCL code defines the intended end-state of the infrastructure. When a manual modification introduces drift, Terraform's `plan` command identifies this deviation by comparing the actual infrastructure with the declared configuration. It then generates a plan to reconcile these differences, proposing actions to bring the actual state back into alignment with the desired state defined in the configuration.

  • A misconfiguration in the Terraform code

    Why it's wrong here

    A misconfiguration in the Terraform code would imply an error or incorrect definition within the HCL itself, leading to an undesired state upon initial application. However, the problem statement indicates that the configuration was successfully applied, and a subsequent manual change caused the discrepancy. This clearly points to an external alteration of the infrastructure, not an inherent flaw or error in the Terraform code's definition.

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.