Complete the code to start a dynamic block for 'ingress' inside a security group.
resource "aws_security_group" "example" { name = "example" dynamic "[1]" { 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 } } }
The dynamic block must be named after the block it generates, here 'ingress'.
Complete the code to start a nested dynamic block for 'cidr_blocks' inside the 'ingress' dynamic block.
resource "aws_security_group" "example" { name = "example" dynamic "ingress" { for_each = var.ingress_rules content { from_port = ingress.value.from_port to_port = ingress.value.to_port protocol = ingress.value.protocol dynamic "[1]" { for_each = ingress.value.cidr_blocks content { cidr_block = cidr_blocks.value } } } } }
The nested dynamic block must be named exactly as the block it generates, which is 'cidr_block'.
Fix the error in the nested dynamic block to correctly reference the current item in 'for_each'.
resource "aws_security_group" "example" { name = "example" dynamic "ingress" { for_each = var.ingress_rules content { from_port = ingress.value.from_port to_port = ingress.value.to_port protocol = ingress.value.protocol dynamic "cidr_block" { for_each = ingress.value.cidr_blocks content { cidr_block = [1] } } } } }
The current item in the nested dynamic block is accessed as 'cidr_block.value'.
Fill both blanks to correctly define a nested dynamic block for 'ipv6_cidr_blocks' inside 'ingress'.
resource "aws_security_group" "example" { name = "example" dynamic "ingress" { for_each = var.ingress_rules content { from_port = ingress.value.from_port to_port = ingress.value.to_port protocol = ingress.value.protocol dynamic "[1]" { for_each = ingress.value.ipv6_cidr_blocks content { cidr_block = [2].value } } } } }
The nested dynamic block name and the variable to access current item must both be 'ipv6_cidr_block'.
Fill all three blanks to create nested dynamic blocks for 'ingress', 'cidr_block', and 'ipv6_cidr_block' inside a security group.
resource "aws_security_group" "example" { name = "example" dynamic "[1]" { for_each = var.ingress_rules content { from_port = ingress.value.from_port to_port = ingress.value.to_port protocol = ingress.value.protocol dynamic "[2]" { for_each = ingress.value.cidr_blocks content { cidr_block = [2].value } } dynamic "[3]" { for_each = ingress.value.ipv6_cidr_blocks content { cidr_block = [3].value } } } } }
The outer dynamic block is 'ingress'. The nested blocks are 'cidr_block' and 'ipv6_cidr_block' respectively.