security.tf 1005 B

1234567891011121314151617181920212223242526
  1. resource "aws_security_group" "re" {
  2. name = "RedisEnterprise"
  3. description = "Redis Enterprise Security Group"
  4. vpc_id = "${var.vpc-id}"
  5. tags = merge({ Name = "RedisEnterprise-${var.vpc-name}" }, var.common-tags)
  6. }
  7. resource "aws_security_group_rule" "variable_rule" {
  8. count = length(var.netrules)
  9. type = "${lookup(var.netrules[count.index], "type")}"
  10. from_port = "${lookup(var.netrules[count.index], "from_port")}"
  11. to_port = "${lookup(var.netrules[count.index], "to_port")}"
  12. protocol = "${lookup(var.netrules[count.index], "protocol")}"
  13. cidr_blocks = "${lookup(var.netrules[count.index], "cidr")}"
  14. security_group_id = "${aws_security_group.re.id}"
  15. }
  16. resource "aws_security_group_rule" "open_nets" {
  17. type = "ingress"
  18. from_port = "0"
  19. to_port = "65535"
  20. protocol = "all"
  21. cidr_blocks = var.open-nets
  22. security_group_id = "${aws_security_group.re.id}"
  23. }