पाठ 21 / 25
What Happens Without moved
A rename that would replace the resource.
Destroy plus create
Without a moved block, renaming the same resource produces a plan to destroy the old address and create the new one. For a file that is harmless; for a database, load balancer or DNS zone it means downtime or data loss. Always read the plan after refactors: an unexpected destroy and create pair with the same arguments is a sign you forgot a moved block.
The same rename without a moved block, run
I ran this with Terraform 1.16.4 and the hashicorp/local 2.9.1 and hashicorp/random 3.9.1 providers, which manage local files and random values, so no cloud account was needed; each example starts from a fresh directory. Renaming without moved plans to create local_file.app_config and destroy local_file.cfg: 1 to add and 1 to destroy.
terraform plan -no-color | grep -E "will be|Plan:"
Output:
# local_file.app_config will be created # local_file.cfg will be destroyed Plan: 1 to add, 0 to change, 1 to destroy.
Look for destroy/create pairs
Matching destroy and create entries after a refactor almost always mean a missing moved block.
त्वरित जाँच: Renaming a resource without moved leads to what plan?
- No changes
- Destroy the old address and create the new one
- An in-place update
- An error that blocks all plans
Answer
Destroy the old address and create the new one — Addresses identify resources.