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?
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).
====================
Catalina
3 days ago