Hi
I am trying to create some ingress rules in Network ACL for AWS using terraform dynamic blocks
I have so far
variable "allowed_ports"{
description = "Allowed Ports"
default = [443,80]
}
resource "aws_network_acl" "myfirewall" {
vpc_id = aws_vpc.myvpc2.id
dynamic "ingress" {
for_each =var.allowed_ports
content {
protocol = "tcp"
rule_no = "${100 + count.index}"
action = "allow"
cidr_block = "0.0.0.0/0"
from_port = ingress.value
to_port = ingress.value
}
}
}
-
The problem that I am running into is incrementing rule_no. How do I do that so that in each iteration of ingress rule, it gets incremented ?
-
Also, if I have a list of cidr_block and want to allow access to port 443 to some a.b.c.d/24 network only and access to port 80 to only m.n.o.p/24 network, how do I do that using dynamic blocks ?