security-groups.tf 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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(var.standard_tags, var.tags)
  11. }
  12. resource "aws_security_group_rule" "vmray_server_http_in_from_workers" {
  13. type = "ingress"
  14. from_port = 80
  15. to_port = 80
  16. protocol = "tcp"
  17. source_security_group_id = aws_security_group.vmray_worker_sg.id
  18. security_group_id = aws_security_group.vmray_server_sg.id
  19. }
  20. resource "aws_security_group_rule" "vmray_server_https_in_from_workers" {
  21. type = "ingress"
  22. from_port = 443
  23. to_port = 443
  24. protocol = "tcp"
  25. source_security_group_id = aws_security_group.vmray_worker_sg.id
  26. security_group_id = aws_security_group.vmray_server_sg.id
  27. }
  28. resource "aws_security_group_rule" "vmray_server_https_in" {
  29. type = "ingress"
  30. from_port = 443
  31. to_port = 443
  32. protocol = "tcp"
  33. #cidr_blocks = var.cidr_map["vpc-access"]
  34. source_security_group_id = aws_security_group.vmray_alb_internal.id
  35. security_group_id = aws_security_group.vmray_server_sg.id
  36. }
  37. ## VMRay Does DNS Lookups to the Local Network
  38. resource "aws_security_group_rule" "vmray_server_tcpdns_out" {
  39. type = "egress"
  40. from_port = 53
  41. to_port = 53
  42. protocol = "tcp"
  43. cidr_blocks = [ var.vpc_info["cidr"] ]
  44. security_group_id = aws_security_group.vmray_server_sg.id
  45. }
  46. resource "aws_security_group_rule" "vmray_server_udpdns_out" {
  47. type = "egress"
  48. from_port = 53
  49. to_port = 53
  50. protocol = "udp"
  51. cidr_blocks = [ var.vpc_info["cidr"] ]
  52. security_group_id = aws_security_group.vmray_server_sg.id
  53. }
  54. ## VMRay Requires Direct Internet Access
  55. resource "aws_security_group_rule" "vmray_server_http_out" {
  56. type = "egress"
  57. from_port = 80
  58. to_port = 80
  59. protocol = "tcp"
  60. cidr_blocks = [ "0.0.0.0/0" ]
  61. security_group_id = aws_security_group.vmray_server_sg.id
  62. }
  63. resource "aws_security_group_rule" "vmray_server_https_out" {
  64. type = "egress"
  65. from_port = 443
  66. to_port = 443
  67. protocol = "tcp"
  68. cidr_blocks = [ "0.0.0.0/0" ]
  69. security_group_id = aws_security_group.vmray_server_sg.id
  70. }
  71. resource "aws_security_group_rule" "vmray_server_vnc_to_workers" {
  72. type = "egress"
  73. from_port = 5900
  74. to_port = 5999
  75. protocol = "tcp"
  76. source_security_group_id = aws_security_group.vmray_worker_sg.id
  77. security_group_id = aws_security_group.vmray_server_sg.id
  78. }
  79. # Workers
  80. resource "aws_security_group" "vmray_worker_sg" {
  81. name = "vmray_worker_sg"
  82. description = "Security Rules for the VMRay Worker Nodes"
  83. vpc_id = var.vpc_id
  84. tags = merge(var.standard_tags, var.tags)
  85. }
  86. resource "aws_security_group_rule" "vmwary_worker_vnc_from_server" {
  87. type = "ingress"
  88. from_port = 5900
  89. to_port = 5999
  90. protocol = "tcp"
  91. source_security_group_id = aws_security_group.vmray_server_sg.id
  92. security_group_id = aws_security_group.vmray_worker_sg.id
  93. }
  94. resource "aws_security_group_rule" "vmwary_worker_vnc_from_access" {
  95. type = "ingress"
  96. from_port = 5900
  97. to_port = 5999
  98. protocol = "tcp"
  99. cidr_blocks = var.cidr_map["vpc-access"]
  100. security_group_id = aws_security_group.vmray_worker_sg.id
  101. }
  102. ## VMRay Does DNS Lookups to the Local Network
  103. resource "aws_security_group_rule" "vmray_worker_tcpdns_out" {
  104. type = "egress"
  105. from_port = 53
  106. to_port = 53
  107. protocol = "tcp"
  108. cidr_blocks = [ var.vpc_info["cidr"] ]
  109. security_group_id = aws_security_group.vmray_worker_sg.id
  110. }
  111. resource "aws_security_group_rule" "vmray_worker_udpdns_out" {
  112. type = "egress"
  113. from_port = 53
  114. to_port = 53
  115. protocol = "udp"
  116. cidr_blocks = [ var.vpc_info["cidr"] ]
  117. security_group_id = aws_security_group.vmray_worker_sg.id
  118. }
  119. resource "aws_security_group_rule" "vmray_worker_http_out" {
  120. type = "egress"
  121. from_port = 80
  122. to_port = 80
  123. protocol = "tcp"
  124. cidr_blocks = [ "0.0.0.0/0" ]
  125. security_group_id = aws_security_group.vmray_worker_sg.id
  126. }
  127. resource "aws_security_group_rule" "vmray_worker_https_out" {
  128. type = "egress"
  129. from_port = 443
  130. to_port = 443
  131. protocol = "tcp"
  132. cidr_blocks = [ "0.0.0.0/0" ]
  133. security_group_id = aws_security_group.vmray_worker_sg.id
  134. }
  135. resource "aws_security_group_rule" "vmray_worker_http_to_server" {
  136. type = "egress"
  137. from_port = 80
  138. to_port = 80
  139. protocol = "tcp"
  140. source_security_group_id = aws_security_group.vmray_server_sg.id
  141. security_group_id = aws_security_group.vmray_worker_sg.id
  142. }
  143. resource "aws_security_group_rule" "vmray_worker_https_to_server" {
  144. type = "egress"
  145. from_port = 443
  146. to_port = 443
  147. protocol = "tcp"
  148. source_security_group_id = aws_security_group.vmray_server_sg.id
  149. security_group_id = aws_security_group.vmray_worker_sg.id
  150. }