security-groups.tf 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # From vmray admin installation guide, page 24
  2. # Clients to server on 443
  3. # Server to workers on 5900-5999 (VNC)
  4. # Workers to server on 80 and 443
  5. # Server
  6. resource "aws_security_group" "vmray_server_sg" {
  7. name = "vmray_server_sg"
  8. description = "Security Rules Specific to VMRay"
  9. vpc_id = var.vpc_id
  10. tags = merge(local.standard_tags, var.tags)
  11. }
  12. resource "aws_security_group_rule" "vmray_server_http_in_from_workers" {
  13. description = "Allow inbound port 80 for redirect from other vmray servers"
  14. type = "ingress"
  15. from_port = 80
  16. to_port = 80
  17. protocol = "tcp"
  18. source_security_group_id = aws_security_group.vmray_worker_sg.id
  19. security_group_id = aws_security_group.vmray_server_sg.id
  20. }
  21. resource "aws_security_group_rule" "vmray_server_https_in_from_workers" {
  22. description = "Allow inbound https for interserver communication from other vmray servers"
  23. type = "ingress"
  24. from_port = 443
  25. to_port = 443
  26. protocol = "tcp"
  27. source_security_group_id = aws_security_group.vmray_worker_sg.id
  28. security_group_id = aws_security_group.vmray_server_sg.id
  29. }
  30. resource "aws_security_group_rule" "vmray_server_https_in" {
  31. description = "Allow https ingress from the VPN"
  32. type = "ingress"
  33. from_port = 443
  34. to_port = 443
  35. protocol = "tcp"
  36. #cidr_blocks = local.cidr_map["vpc-access"]
  37. source_security_group_id = aws_security_group.vmray_alb_internal.id
  38. security_group_id = aws_security_group.vmray_server_sg.id
  39. }
  40. ## VMRay Does DNS Lookups to the Local Network
  41. resource "aws_security_group_rule" "vmray_server_tcpdns_out" {
  42. description = "Allow DNS lookups to the local DNS server"
  43. type = "egress"
  44. from_port = 53
  45. to_port = 53
  46. protocol = "tcp"
  47. cidr_blocks = [var.vpc_info["cidr"]]
  48. security_group_id = aws_security_group.vmray_server_sg.id
  49. }
  50. resource "aws_security_group_rule" "vmray_server_udpdns_out" {
  51. description = "Allow DNS lookups to the local DNS server"
  52. type = "egress"
  53. from_port = 53
  54. to_port = 53
  55. protocol = "udp"
  56. cidr_blocks = [var.vpc_info["cidr"]]
  57. security_group_id = aws_security_group.vmray_server_sg.id
  58. }
  59. # tfsec:ignore:aws-vpc-no-public-egress-sgr VMRay Requires Direct Internet Access
  60. resource "aws_security_group_rule" "vmray_server_http_out" {
  61. description = "VMRay requires direct HTTP outbound"
  62. type = "egress"
  63. from_port = 80
  64. to_port = 80
  65. protocol = "tcp"
  66. cidr_blocks = ["0.0.0.0/0"]
  67. security_group_id = aws_security_group.vmray_server_sg.id
  68. }
  69. # tfsec:ignore:aws-vpc-no-public-egress-sgr VMRay Requires Direct Internet Access
  70. resource "aws_security_group_rule" "vmray_server_https_out" {
  71. description = "VMRay requires direct HTTPS outbound"
  72. type = "egress"
  73. from_port = 443
  74. to_port = 443
  75. protocol = "tcp"
  76. cidr_blocks = ["0.0.0.0/0"]
  77. security_group_id = aws_security_group.vmray_server_sg.id
  78. }
  79. resource "aws_security_group_rule" "vmray_server_vnc_to_workers" {
  80. description = "VMRay uses VNC for client machine access."
  81. type = "egress"
  82. from_port = 5900
  83. to_port = 5999
  84. protocol = "tcp"
  85. source_security_group_id = aws_security_group.vmray_worker_sg.id
  86. security_group_id = aws_security_group.vmray_server_sg.id
  87. }
  88. # Workers
  89. resource "aws_security_group" "vmray_worker_sg" {
  90. name = "vmray_worker_sg"
  91. description = "Security Rules for the VMRay Worker Nodes"
  92. vpc_id = var.vpc_id
  93. tags = merge(local.standard_tags, var.tags)
  94. }
  95. resource "aws_security_group_rule" "vmwary_worker_vnc_from_server" {
  96. description = "VMRay uses VNC for client machine access."
  97. type = "ingress"
  98. from_port = 5900
  99. to_port = 5999
  100. protocol = "tcp"
  101. source_security_group_id = aws_security_group.vmray_server_sg.id
  102. security_group_id = aws_security_group.vmray_worker_sg.id
  103. }
  104. resource "aws_security_group_rule" "vmwary_worker_vnc_from_access" {
  105. description = "VMRay uses VNC for client machine access."
  106. type = "ingress"
  107. from_port = 5900
  108. to_port = 5999
  109. protocol = "tcp"
  110. cidr_blocks = local.cidr_map["vpc-access"]
  111. security_group_id = aws_security_group.vmray_worker_sg.id
  112. }
  113. resource "aws_security_group_rule" "vmray_worker_tcpdns_out" {
  114. description = "VMRay does DNS lookups to an instance in the local vpc."
  115. type = "egress"
  116. from_port = 53
  117. to_port = 53
  118. protocol = "tcp"
  119. cidr_blocks = [var.vpc_info["cidr"]]
  120. security_group_id = aws_security_group.vmray_worker_sg.id
  121. }
  122. resource "aws_security_group_rule" "vmray_worker_udpdns_out" {
  123. description = "VMRay does DNS lookups to an instance in the local vpc."
  124. type = "egress"
  125. from_port = 53
  126. to_port = 53
  127. protocol = "udp"
  128. cidr_blocks = [var.vpc_info["cidr"]]
  129. security_group_id = aws_security_group.vmray_worker_sg.id
  130. }
  131. # tfsec:ignore:aws-vpc-no-public-egress-sgr VMRay Requires Direct Internet Access
  132. resource "aws_security_group_rule" "vmray_worker_http_out" {
  133. description = "VMRay requires direct HTTP access."
  134. type = "egress"
  135. from_port = 80
  136. to_port = 80
  137. protocol = "tcp"
  138. cidr_blocks = ["0.0.0.0/0"]
  139. security_group_id = aws_security_group.vmray_worker_sg.id
  140. }
  141. # tfsec:ignore:aws-vpc-no-public-egress-sgr VMRay Requires Direct Internet Access
  142. resource "aws_security_group_rule" "vmray_worker_https_out" {
  143. description = "VMRay requires direct HTTPS access."
  144. type = "egress"
  145. from_port = 443
  146. to_port = 443
  147. protocol = "tcp"
  148. cidr_blocks = ["0.0.0.0/0"]
  149. security_group_id = aws_security_group.vmray_worker_sg.id
  150. }
  151. resource "aws_security_group_rule" "vmray_worker_http_to_server" {
  152. description = "VMRay worker communicates with the server."
  153. type = "egress"
  154. from_port = 80
  155. to_port = 80
  156. protocol = "tcp"
  157. source_security_group_id = aws_security_group.vmray_server_sg.id
  158. security_group_id = aws_security_group.vmray_worker_sg.id
  159. }
  160. resource "aws_security_group_rule" "vmray_worker_https_to_server" {
  161. description = "VMRay worker communicates with the server."
  162. type = "egress"
  163. from_port = 443
  164. to_port = 443
  165. protocol = "tcp"
  166. source_security_group_id = aws_security_group.vmray_server_sg.id
  167. security_group_id = aws_security_group.vmray_worker_sg.id
  168. }