security.tf 3.8 KB

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