HashiCorp
TERRAFORM-ASSOCIATE-004 · Question #242
You modified your Terraform configuration to fix a typo in the resource ID by renaming it from photoes to photos. What configuration will you add to update the resource ID in state without destroying
The correct answer is A. moved {. Terraform does not automatically update state references when resource identifiers are renamed. Instead, you must use a moved block in your configuration to inform Terraform how to map the old resource to the new one. This prevents Terraform from destroying and recreating the
Submitted by yaw92· Apr 18, 2026Manage Terraform State
Question
You modified your Terraform configuration to fix a typo in the resource ID by renaming it from photoes to photos. What configuration will you add to update the resource ID in state without destroying the existing resource? Original configuration: resource "aws_s3_bucket" "photoes" { bucket_prefix = "images" } Updated configuration: resource "aws_s3_bucket" "photos" { bucket_prefix = "images" }
Options
- Amoved {
- Bmoved {
- Cmoved {
- DNone. Terraform will automatically update the resource ID.
How the community answered
(30 responses)- A83% (25)
- B3% (1)
- C7% (2)
- D7% (2)
Explanation
Terraform does not automatically update state references when resource identifiers are renamed. Instead, you must use a moved block in your configuration to inform Terraform how to map the old resource to the new one. This prevents Terraform from destroying and recreating the
Topics
#moved block#resource renaming#state management#refactoring
Community Discussion
No community discussion yet for this question.