resource “aws_network_acl” “nacl100” {
vpc_id = aws_vpc.vpc_east1.id
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.public_subnets[0]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 10
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.public_subnets[1]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 20
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.public_subnets[2]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 30
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.private_subnets_web[0]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 40
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.private_subnets_web[1]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 50
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.private_subnets_web[2]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 50
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.private_subnets_db[0]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 60
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.private_subnets_db[1]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 70
to_port = ingress.value
}
}
dynamic “ingress” {
for_each = var.ports
content {
action = "allow"
cidr_block = var.private_subnets_db[2]
from_port = ingress.value
icmp_code = 1
icmp_type = 1
protocol = "tcp"
rule_no = 80
to_port = ingress.value
}
}
egress {
action = "deny"
cidr_block = "0.0.0.0/0"
from_port = 0
icmp_code = 1
icmp_type = 1
protocol = "-1"
rule_no = 90
to_port = 0
}
}
can be add rule no automatically with help of dynamic block