Terraform count Is Not a Loop — And That Matters

Most developers treat Terraform count like a programming loop.

That mental model is wrong.

count does not repeat a single object.
It creates numbered state identities.

Each index becomes part of the resource’s address.
Address becomes identity.
Identity controls destroy and create behavior.

Change the number, and infrastructure changes.
Reorder a list, and Terraform may destroy the wrong server.

This lesson explains why count is really about positional identity — not iteration — and why that distinction matters in production environments.

If you’ve ever been surprised by Terraform replacing something unexpectedly, this mental model will clarify why it happened.

Terraform does not loop.

It constructs indexed reality.