Courseiva
Understand Terraform's purposehardMultiple ChoiceObjective-mapped

TF-004 Understand Terraform's purpose Practice Question

A DevOps engineer runs terraform plan and sees that a resource will be destroyed and recreated, but they expected an in-place update. The resource is an AWS EC2 instance with a specific AMI. Which attribute change is most likely causing the destruction?

⚠ Common exam trap

A common misconception is that any attribute change requiring a stop/start (like instance type) results in destroy-and-recreate, but in Terraform, stop/start is still an in-place update unless the attribute is explicitly marked `ForceNew`.

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

The AMI ID was changed.

Changing the AMI ID of an AWS EC2 instance is a force-new attribute in Terraform. Because the AMI defines the root block device and operating system, Terraform cannot perform an in-place update; it must destroy the existing instance and create a new one with the new AMI. This behavior is hardcoded in the Terraform AWS provider for the `aws_instance` resource.

Answer analysis

Option-by-option breakdown

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

  • The AMI ID was changed.

    Why this is correct

    Changing the Amazon Machine Image (AMI) ID for an EC2 instance resource in Terraform necessitates a full replacement of the instance. This is because the AMI defines the operating system and initial software configuration of the instance's root volume at launch time. Since the root volume is intrinsically tied to the AMI used for its creation, an update to the AMI ID cannot be applied in-place to an already running instance, thus forcing Terraform to destroy the old instance and create a new one.

  • The security group list was modified.

    Why it's wrong here

    Modifying the list of associated security groups for an EC2 instance typically results in an in-place update rather than a replacement. AWS APIs allow security group associations to be added or removed from a running instance dynamically without requiring it to be stopped or terminated. Terraform recognizes this capability and applies the changes directly to the existing instance resource, avoiding any destructive actions.

  • The tags were updated.

    Why it's wrong here

    Updating tags on an AWS EC2 instance is a metadata change that Terraform handles as an in-place modification. Tags are key-value pairs used for organization and billing, and their alteration does not affect the fundamental operational characteristics or underlying infrastructure of the instance. Consequently, Terraform simply updates the tag values on the existing resource via the AWS API without triggering its destruction and recreation.

  • The instance type was reduced from large to micro.

    Why it's wrong here

    Changing an EC2 instance's type, such as reducing it from large to micro, generally triggers an in-place update that requires the instance to be stopped and then restarted. While this operation causes temporary downtime, it does not necessitate the complete replacement (destruction and recreation) of the EC2 instance resource itself. Terraform manages this by issuing the appropriate API calls to modify the existing instance's attributes.

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.