Generating multiple blocks with the dynamic block
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_configblock inside theazurerm_linux_web_appresource
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://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group).
One of the great features of Terraform is the dynamic block, which allows us to loop the blocks in resources.
In this recipe, we will see how to use the dynamic block to provision an azurerm_network_security_group resource in Azure...