Terraform

What's a for_each loop? How is it different from "count"?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

  • for_each can applied only on collections like maps or sets (as opposed to count that can be applied on lists)
  • for_each helps to deal with the limitation of count which isn't optimal for use cases of modifying lists
  • for_each supports inline blocks as opposed to count