Generating multiple blocks with dynamic expressions
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_linux_web_app
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://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group).
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 feature Terraform is the dynamic
expression...