Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

HashiCorp Terraform-Associate-004 Exam - Topic 7 Question 9 Discussion

Posted by Chu on May 04, 2026 at 10:08 PM

You corrected a typo in a resource name, changing it from aws_s3_bucket.photoes to aws_s3_bucket.photos. You want to update the Terraform state so that the existing resource is recognized under the new name, without destroying and recreating it. Which configuration should you use?

Suggested Answer: D

Rationale for Correct Answer: A moved block tells Terraform that an object's address in state has changed (renamed/refactored) and it should move the state from the old address to the new address. This preserves the existing real resource and prevents unnecessary destroy/recreate.

Analysis of Incorrect Options (Distractors):

A: Works but is unnecessarily risky/extra work; moved is the intended refactoring mechanism for renames.

B: Incorrect---refresh-only updates state to match real infrastructure, but it does not remap an object from one address to another.

C: Incorrect---Terraform will treat the new name as a new resource address and the old one as removed unless you explicitly move/rename state.

Key Concept: Refactoring addresses safely using moved blocks (state address migration).


====================

Get Premium Terraform-Associate-004 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
28 comments · newest first
ME
Merilyn 4 days ago
Exactly! D handles the rename smoothly.
RO
Rosio 9 days ago
But A could lead to issues. D is cleaner.
CA
Carla 15 days ago
I’m leaning towards A. Re-importing feels safer.
KA
Katy 20 days ago
Agreed, D makes sense. It keeps the state intact.
ME
Merilyn 25 days ago
I think D is the best choice. The moved block is designed for this.
TR
Tracey 1 month ago
Agreed, we need to be proactive with the state management.
SH
Shawnta 1 month ago
Option C is definitely not a good idea. Terraform won't auto-update.
CA
Carma 1 month ago
Exactly, we need to ensure the state reflects the new name.
DE
Della 2 months ago
But it won't update the name properly, right?
TR
Tracey 2 months ago
True, but option B seems like a safe bet too.
SH
Shawnta 2 months ago
I feel like option A is risky. Re-importing can cause issues.
CA
Carma 2 months ago
Yeah, adding a moved block makes sense.
DE
Della 2 months ago
I think option D is the best choice.
MO
Moon 2 months ago
Right? Better to be explicit with D.
MI
Ming 3 months ago
I feel like C is too optimistic. Terraform doesn't always auto-update.
EI
Eileen 3 months ago
Exactly! We want to avoid destruction. D is safer.
AL
Alton 3 months ago
Option A seems risky. Removing the resource could lead to issues.
PE
Pete 3 months ago
Yeah, I agree. The moved block keeps everything organized.
JE
Jean 3 months ago
I think option D is the best choice. It clearly indicates the resource has moved.
CO
Corazon 3 months ago
B won't help with the name change, just saying.
RE
Refugia 4 months ago
Wait, does D really work without issues?
ZA
Zana 4 months ago
A is too much hassle, just use D!
FR
France 4 months ago
I thought Terraform auto-updated states?
MO
Mohammad 4 months ago
D is the way to go!
LA
Laurel 4 months ago
I recall that removing the old resource and re-importing it could lead to issues, so I’d lean towards option D.
AS
Asuncion 6 months ago
I thought Terraform automatically updates the state, but I guess that might not apply in this case?
DA
Daniel 6 months ago
I’m not entirely sure, but I feel like option D sounds familiar from a practice question about moving resources.
CA
Catalina 6 months ago
I think I remember that when you rename a resource, you might need to tell Terraform about the change explicitly.
0/2000 characters

Save Cancel