Skip to content

Commit 8b25db3

Browse files
authored
Merge pull request #1 from buildo/support-port-ranges
Support port ranges in security groups
2 parents ae49f19 + 8ab3d27 commit 8b25db3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

security_group.tf

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ resource "aws_security_group_rule" "custom_ports" {
2525
type = "ingress"
2626
protocol = "tcp"
2727
security_group_id = "${aws_security_group.sg.id}"
28-
from_port = "${element(var.in_open_ports, count.index)}"
29-
to_port = "${element(var.in_open_ports, count.index)}"
28+
from_port = "${2 == length(split("-", element(var.in_open_ports, count.index))) ?
29+
element(split("-", element(var.in_open_ports, count.index)), 0) :
30+
element(var.in_open_ports, count.index) }"
31+
to_port = "${2 == length(split("-", element(var.in_open_ports, count.index))) ?
32+
element(split("-", element(var.in_open_ports, count.index)), 1) :
33+
element(var.in_open_ports, count.index) }"
3034
cidr_blocks = ["0.0.0.0/0"]
3135
}

0 commit comments

Comments
 (0)