security.tf 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. # Ingress
  8. ###############################################################################
  9. # SSH Internal
  10. ingress {
  11. from_port = 22
  12. to_port = 22
  13. protocol = "tcp"
  14. cidr_blocks = [var.vpc-cidr]
  15. }
  16. # SSH External
  17. ingress {
  18. from_port = 22
  19. to_port = 22
  20. protocol = "tcp"
  21. cidr_blocks = var.open-nets
  22. }
  23. ###############################################################################
  24. # Redis Enterprise Specific
  25. # https://docs.redislabs.com/latest/rs/administering/designing-production/networking/port-configurations
  26. ###############################################################################
  27. # For connectivity checking between nodes
  28. ingress {
  29. from_port = -1
  30. to_port = -1
  31. protocol = "icmp"
  32. cidr_blocks = [var.vpc-cidr]
  33. }
  34. # Internal cluster usage
  35. ingress {
  36. from_port = 3333
  37. to_port = 3339
  38. protocol = "tcp"
  39. cidr_blocks = [var.vpc-cidr]
  40. }
  41. ingress {
  42. from_port = 36379
  43. to_port = 36380
  44. protocol = "tcp"
  45. cidr_blocks = [var.vpc-cidr]
  46. }
  47. # For application to access the RS Discovery Service
  48. ingress {
  49. from_port = 8001
  50. to_port = 8001
  51. protocol = "tcp"
  52. cidr_blocks = [var.vpc-cidr]
  53. }
  54. # For secure (https) access to the management web UI
  55. ingress {
  56. from_port = 8443
  57. to_port = 8443
  58. protocol = "tcp"
  59. cidr_blocks = var.open-nets
  60. }
  61. # For nginx <->cnm_http/cm communications on the same host only. Ports are bound to loopback adapter.
  62. ingress {
  63. from_port = 8444
  64. to_port = 8444
  65. protocol = "tcp"
  66. cidr_blocks = [var.vpc-cidr]
  67. }
  68. ingress {
  69. from_port = 9080
  70. to_port = 9080
  71. protocol = "tcp"
  72. cidr_blocks = [var.vpc-cidr]
  73. }
  74. # For CRDB management
  75. ingress {
  76. from_port = 9081
  77. to_port = 9081
  78. protocol = "tcp"
  79. cidr_blocks = [var.vpc-cidr]
  80. }
  81. # For metrics exported and managed by nginx
  82. ingress {
  83. from_port = 8070
  84. to_port = 8071
  85. protocol = "tcp"
  86. cidr_blocks = [var.vpc-cidr]
  87. }
  88. # Used to expose the REST API, including cluster management and node bootstrap
  89. ingress {
  90. from_port = 8080
  91. to_port = 8080
  92. protocol = "tcp"
  93. cidr_blocks = [var.vpc-cidr]
  94. }
  95. ingress {
  96. from_port = 9443
  97. to_port = 9443
  98. protocol = "tcp"
  99. cidr_blocks = [var.vpc-cidr]
  100. }
  101. # For exposing databases externally
  102. ingress {
  103. from_port = 10000
  104. to_port = 19999
  105. protocol = "tcp"
  106. cidr_blocks = var.open-nets
  107. }
  108. # For internal communications with database shards
  109. ingress {
  110. from_port = 20000
  111. to_port = 29999
  112. protocol = "tcp"
  113. cidr_blocks = [var.vpc-cidr]
  114. }
  115. # For accessing DNS/mDNS functionality in the cluster
  116. ingress {
  117. from_port = 53
  118. to_port = 53
  119. protocol = "udp"
  120. cidr_blocks = [var.vpc-cidr]
  121. }
  122. ingress {
  123. from_port = 5353
  124. to_port = 5353
  125. protocol = "udp"
  126. cidr_blocks = [var.vpc-cidr]
  127. }
  128. ###############################################################################
  129. # Egress
  130. ###############################################################################
  131. egress {
  132. from_port = 0
  133. to_port = 65535
  134. protocol = "tcp"
  135. cidr_blocks = ["0.0.0.0/0"]
  136. }
  137. egress {
  138. from_port = -1
  139. to_port = -1
  140. protocol = "icmp"
  141. cidr_blocks = [var.vpc-cidr]
  142. }
  143. egress {
  144. from_port = 0
  145. to_port = 65535
  146. protocol = "udp"
  147. cidr_blocks = ["0.0.0.0/0"]
  148. }
  149. }