Complete the code to start a dynamic block in Terraform.
dynamic "[1]" { for_each = var.items content { cidr_blocks = [each.value] } }
The dynamic block name should match the block you want to repeat, such as ingress for security group rules.
Complete the code to access each item in the dynamic block.
content {
cidr_blocks = [each.value.[1]]
}Each item in the list should have a property named cidr_block to access the CIDR range.
Fix the error in the dynamic block to correctly iterate over a list.
dynamic "ingress" { for_each = [1] content { from_port = each.value.from_port to_port = each.value.to_port protocol = each.value.protocol } }
The variable should be the list of ingress rules, typically named ingress_rules.
Fill both blanks to add the Name tag to the resource.
resource "aws_instance" "example" { ami = var.ami instance_type = var.instance_type tags = { [1] = [2] } }
The tag key is 'Name' and its value comes from var.name.
Fill all three blanks to define a dynamic block for multiple security group egress rules.
dynamic "egress" { for_each = [1] content { from_port = each.value.[2] to_port = each.value.[3] protocol = each.value.protocol } }
The dynamic block iterates over var.egress_rules, accessing from_port and to_port properties for each rule.