Terraform Dynamic Block
Last updated
Last updated
Dynamically constructs repeatable nested configuration blocks inside Terraform resources.
Supported within the block types:
resource
data
provider
provisioner
Use to make your code cleaner
Dynamic blocks expect a complex variable type to iterate over.
It acts like a for-loop and outputs a nested block for each element in your variable.
Be careful not to overuse dynamic blocks in your main code, as they can be hard to read and maintain
Only use dynamic blocks when you need to hide details in order to build a cleaner user interface when writing reusable modules.