DEV Community

Rahul Wagh
Rahul Wagh

Posted on • Originally published at jhooq.com

What are Terraform Dynamic blocks? - Part 8

Terraform dynamic block behaves pretty much the same as for or for-each loop. It not only iterates over the value range but also creates nested dynamic blocks which can be complex.

Terraform dynamic block usually consists of three elements -

  1. Name of dynamic block
  2. for_each
  3. content

  4. Name of dynamic block - You can keep the name of the block as per your choice, terraform does not have very strict rules on defining the dynamic block names

  5. for_each - Here you need to provide any collection or structural values which can be iterated

  6. content - It is a terraform block or body which will be generated for each value of the for-each loop

Terraform dynamic block - https://jhooq.com/terraform-dynamic-block/

Discussion (0)