Most engineers think Terraform identifies resources by tags or configuration similarity. It does not. Terraform identifies infrastructure by address.
A resource address is the exact key Terraform uses inside the state file. If that address changes, Terraform treats the object as new. That is why refactors involving count, for_each, or module moves can trigger destroy and recreate actions even when nothing “looks” different.
In this lesson, I break down:
- Why address equals identity
- How
countbinds identity to integer indexes - Why
for_eachrequires a map or set and howtoset()prevents type errors - How module paths mutate addresses
- Why targeting operates strictly on addresses
If you want to refactor Terraform safely, you must understand addressing as a state contract, not a naming detail.

