Terraform HCL Loops With count and for_each

Terraform HCL Loops With count and for_each

In this video, we’ll cover Terraform looping constructs. Terraform is declarative, so it’s looping structure may seem weird to those used to procedural programming loops. There are a few ways to performing looping with Terraform. We’ll cover the looping constructs that specifically work at the resource level. They handle resource creation itself. There are two of them.

  1. count: This is often brought up when talking about looping with Terraform.
  2. for_each: This technique is similar to the count method but has some advantages. It should be generally used over count. We’ll explain why in this video.