Deployment, Provisioning, and Automation

A team renames a Terraform resource block without changing its arguments, and the plan proposes destroying and recreating the existing AWS resource. The migration must be recorded in version control and applied consistently across workspaces; what should the team do?

Show the answer

Correct answerC. Add a moved block mapping the old address to the new address

AWhy not this: The resource is already managed; importing at its existing address does not record its move to the new address.

BWhy not this: Removing the binding makes Terraform stop tracking the existing resource and can lead to attempted creation at the new address.

CWhy this is right: A moved block declaratively maps the old resource address to the new one without recreating the AWS resource.

DWhy not this: Preventing destruction can stop a destructive plan but does not associate the renamed block with the existing resource.

A moved block records a resource-address change so Terraform preserves the existing resource during refactoring, and it can be committed for use across workspaces. Preventing destruction blocks the proposed operation but does not establish the mapping between the old and new addresses.