Generate repeated nested blocks from input data.

Section: Dynamic Blocks and Data Sources

Dynamic block

hcl
hcl
dynamic "ingress" {
  for_each = var.ingress_rules
  content {
    from_port   = ingress.value.from_port
    to_port     = ingress.value.to_port
    protocol    = ingress.value.protocol
    cidr_blocks = ingress.value.cidr_blocks
  }
}
Explanation

Generate repeated nested blocks from input data.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Dynamic Blocks and Data Sources
Data source example
Query existing infrastructure data for use in resources.
OpenIn sheethclsame section
String variable
Declare a typed string variable.
OpenIn sheethcl1 tag match
Use count
Create multiple similar resources with count.
OpenIn sheethcl1 tag match
Conditional expression
Choose values conditionally.
OpenIn sheethcl1 tag match
Object variable
Declare a typed object variable.
OpenIn sheethcl1 tag match
Use for_each
Create resources keyed by map/set members.
OpenIn sheethcl1 tag match