Explain it in 60 seconds
count vs for_each
Cloud & DevOps · Terraform and IaC · Beginner
What are count and for_each, and when do you use each?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Create multiple instances of resource/module.
- count: number, indexed [0], [1].
- for_each: map/set, keyed by name.
- Removing middle item with count shifts indexes.
- Prefer for_each for named items.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.