diff --git a/main.tf b/main.tf index 460000e..39b835c 100644 --- a/main.tf +++ b/main.tf @@ -27,10 +27,10 @@ resource "aws_security_group_rule" "this" { for_each = toset(var.ingress_cidrs) cidr_blocks = [each.key] - from_port = 22 + from_port = var.instance_security_group_ports[0] protocol = "tcp" security_group_id = aws_security_group.this.id - to_port = 22 + to_port = var.instance_security_group_ports[count.index % length(var.instance_security_group_ports)] type = "ingress" } diff --git a/variables.tf b/variables.tf index 06ff80d..f0e62a2 100644 --- a/variables.tf +++ b/variables.tf @@ -113,3 +113,7 @@ variable "instance_profile" { # } } +variable "instance_security_group_ports" { + default = [22] + description = "Set allow ports for the EC2 instance" +}