resource "aws_security_group" "re" { name = "RedisEnterprise" description = "Redis Enterprise Security Group" vpc_id = "${var.vpc-id}" tags = merge({ Name = "RedisEnterprise-${var.vpc-name}" }, var.common-tags) } resource "aws_security_group_rule" "variable_rule" { count = length(var.netrules) type = "${lookup(var.netrules[count.index], "type")}" from_port = "${lookup(var.netrules[count.index], "from_port")}" to_port = "${lookup(var.netrules[count.index], "to_port")}" protocol = "${lookup(var.netrules[count.index], "protocol")}" cidr_blocks = "${lookup(var.netrules[count.index], "cidr")}" security_group_id = "${aws_security_group.re.id}" } resource "aws_security_group_rule" "open_nets" { type = "ingress" from_port = "0" to_port = "65535" protocol = "all" cidr_blocks = var.open-nets security_group_id = "${aws_security_group.re.id}" }