DEV Community

Spacelift team for Spacelift

Posted on • Edited on • Originally published at spacelift.io

Terraform count in Practice

Terraform count meta-argument is a simple way to create multiple instances of a resource — but it comes with sharp edges. The biggest one is that count relies on numeric indexes, so changes in ordering (or switching to a different pattern later) can lead to surprising diffs and painful refactors.

In the full guide, we cover:

  • What count does and how it behaves during plan/apply
  • Common patterns: conditional resources, repeated resources, and “toggle” behavior
  • The most common gotchas (index shifts, address stability, and lifecycle surprises)
  • How to decide between count and for_each in real projects
  • Tips for evolving configurations without breaking resource addresses

➡️ Read the full article on our blog:

https://spacelift.io/blog/terraform-count

Top comments (1)

Collapse
 
grapplingdev profile image
Dan

Awesome article!

We just posted a Terraform roadmap over at roadmap.sh/terraform!