Terraform resources are defined by the following elements:
- Properties that are in the form property name = value, which we have seen several times in this book
- Blocks that represent a grouping of properties, such as the site_config block inside the azurerm_app_service resource
Depending on the Terraform resource, a block can be present once or even multiple times in the same resource, such as the security_rule block inside the azurerm_network_security_group resource (see the documentation, for example, at https://www.terraform.io/docs/providers/azurerm/r/network_security_group.html).
Until Terraform version 0.12, it was not possible to make these blocks present several times in the same resource dynamically using, for example, a variable of list type.
One of the great novelties of Terraform 0.12 is the new dynamic expression that allows us to loop the blocks in resources.
In this recipe, we will see how to use the dynamic expression...