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 -
- Name of dynamic block
- for_each
content
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
for_each - Here you need to provide any collection or structural values which can be iterated
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/
Top comments (0)