StudyToCert

All certifications / Terraform Associate / Lessons

HashiCorp Certified: Terraform Associate Terraform Associate (004) · Domain 7: Maintain infrastructure with Terraform

Refactoring: `moved` blocks and `terraform state mv`

▶ Watch the overview video

Last reviewed September 25, 2026 · Leer en español

As configurations grow, you rename resources, move them into modules and switch from count to for_each. Each of these changes the resource's address. Terraform tracks objects by address, so if you simply rename aws_instance.web to aws_instance.frontend, the plan shows the old address being destroyed and a new one being created. For a database or a production server, that is exactly what you do not want. Refactoring tools tell Terraform that the object has only moved.

Free account

Keep reading for free

Create a free StudyToCert account to read the rest of this lesson: 5 more sections, 4 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.

Sign up free Log in

Study Terraform Associate for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the Terraform Associate study plan