Question 191 of 519
Understand Terraform basicsmediumMultiple ChoiceObjective-mapped

Quick Answer

The answer is to set `create_before_destroy = true` and add `instance_type` to `ignore_changes`. This combination works because `create_before_destroy` instructs Terraform to provision the new resource before destroying the old one, ensuring zero-downtime replacement when the AMI ID changes, while `ignore_changes` on `instance_type` tells Terraform to disregard any modifications to that specific attribute, preventing unnecessary replacement. On the HashiCorp Terraform Associate TF-003 exam, this scenario tests your understanding of how lifecycle meta-arguments interact—specifically that `create_before_destroy` applies to all changes that trigger replacement, and `ignore_changes` selectively exempts attributes from that trigger. A common trap is assuming `create_before_destroy` alone solves the problem, but it only controls the order of replacement, not which changes cause it. Memory tip: think of `create_before_destroy` as "build the new bridge before burning the old one," and `ignore_changes` as "don't rebuild the house just because you painted the door."

TF-003 Understand Terraform basics Practice Question

This TF-003 practice question tests your understanding of understand terraform basics. This is a configuration task: choose the command set that satisfies every stated requirement. Small differences — like 'secret' vs 'password' or 'transport input ssh' vs 'all' — change whether the answer is correct. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A DevOps engineer is writing a Terraform configuration to provision an AWS EC2 instance. They want to ensure that the instance is replaced if the AMI ID changes, but not if the instance type changes. Which lifecycle meta-argument should be used?

Question 1mediummultiple choice
Full question →

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

Set `create_before_destroy = true` and add `instance_type` to `ignore_changes`

Option C is correct because `create_before_destroy = true` ensures the new instance is created before the old one is destroyed, which is a best practice for zero-downtime deployments when the AMI changes. Adding `instance_type` to `ignore_changes` tells Terraform to ignore changes to the instance type attribute during plan/apply, so the instance is not replaced when only the instance type changes. This combination precisely meets the requirement: replacement on AMI change, no replacement on instance type change.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

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

  • Set `prevent_destroy = true`

    Why it's wrong here

    Prevents any destruction, which is too restrictive.

  • Set `ignore_changes = all`

    Why it's wrong here

    Ignores all changes, so AMI change wouldn't trigger replacement.

  • Set `create_before_destroy = true` and add `instance_type` to `ignore_changes`

    Why this is correct

    Correct: creates new before destroying old, ignores instance type changes.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Set `create_before_destroy = true` only

    Why it's wrong here

    Would still cause replacement on instance type change, not desired.

Common exam traps

Common exam trap: answer the scenario, not the keyword

HashiCorp often tests the misconception that `create_before_destroy` alone controls replacement behavior, when in fact it only controls the order of operations and must be combined with `ignore_changes` to selectively prevent replacement on specific attributes.

Detailed technical explanation

How to think about this question

Under the hood, Terraform's `ignore_changes` meta-argument works by comparing the current state with the configuration and, for listed attributes, suppressing the diff that would trigger a resource update or replacement. The `create_before_destroy` lifecycle option modifies the default destroy-before-create behavior, which is critical for stateful resources like EC2 instances where you want to minimize downtime. In real-world scenarios, this pattern is often used with auto-scaling groups or load balancers to ensure that an AMI update (e.g., a security patch) triggers a rolling replacement, while instance type changes (e.g., scaling vertically) are handled separately via other mechanisms like instance resize.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A small business has 20 workstations on the 192.168.1.0/24 network and one public IP from its ISP. The router uses PAT (NAT overload) so all 20 devices share one public address using different source ports. NAT questions test whether you understand the four address terms and which direction each translation applies.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related TF-003 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free TF-003 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this TF-003 question test?

Understand Terraform basics — This question tests Understand Terraform basics — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Set `create_before_destroy = true` and add `instance_type` to `ignore_changes` — Option C is correct because `create_before_destroy = true` ensures the new instance is created before the old one is destroyed, which is a best practice for zero-downtime deployments when the AMI changes. Adding `instance_type` to `ignore_changes` tells Terraform to ignore changes to the instance type attribute during plan/apply, so the instance is not replaced when only the instance type changes. This combination precisely meets the requirement: replacement on AMI change, no replacement on instance type change.

What should I do if I get this TF-003 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This TF-003 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-003 exam.