security-groups.tf 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 Requires Direct Internet Access
  38. resource "aws_security_group_rule" "vmray_server_http_out" {
  39. type = "egress"
  40. from_port = 80
  41. to_port = 80
  42. protocol = "tcp"
  43. cidr_blocks = [ "0.0.0.0/0" ]
  44. security_group_id = aws_security_group.vmray_server_sg.id
  45. }
  46. resource "aws_security_group_rule" "vmray_server_https_out" {
  47. type = "egress"
  48. from_port = 443
  49. to_port = 443
  50. protocol = "tcp"
  51. cidr_blocks = [ "0.0.0.0/0" ]
  52. security_group_id = aws_security_group.vmray_server_sg.id
  53. }
  54. resource "aws_security_group_rule" "vmray_server_vnc_to_workers" {
  55. type = "egress"
  56. from_port = 5900
  57. to_port = 5999
  58. protocol = "tcp"
  59. source_security_group_id = aws_security_group.vmray_worker_sg.id
  60. security_group_id = aws_security_group.vmray_server_sg.id
  61. }
  62. # Workers
  63. resource "aws_security_group" "vmray_worker_sg" {
  64. name = "vmray_worker_sg"
  65. description = "Security Rules for the VMRay Worker Nodes"
  66. vpc_id = var.vpc_id
  67. tags = merge(var.standard_tags, var.tags)
  68. }
  69. resource "aws_security_group_rule" "vmwary_worker_vnc_from_server" {
  70. type = "ingress"
  71. from_port = 5900
  72. to_port = 5999
  73. protocol = "tcp"
  74. source_security_group_id = aws_security_group.vmray_server_sg.id
  75. security_group_id = aws_security_group.vmray_worker_sg.id
  76. }
  77. resource "aws_security_group_rule" "vmray_worker_http_out" {
  78. type = "egress"
  79. from_port = 80
  80. to_port = 80
  81. protocol = "tcp"
  82. cidr_blocks = [ "0.0.0.0/0" ]
  83. security_group_id = aws_security_group.vmray_worker_sg.id
  84. }
  85. resource "aws_security_group_rule" "vmray_worker_https_out" {
  86. type = "egress"
  87. from_port = 443
  88. to_port = 443
  89. protocol = "tcp"
  90. cidr_blocks = [ "0.0.0.0/0" ]
  91. security_group_id = aws_security_group.vmray_worker_sg.id
  92. }
  93. resource "aws_security_group_rule" "vmray_worker_http_to_server" {
  94. type = "egress"
  95. from_port = 80
  96. to_port = 80
  97. protocol = "tcp"
  98. source_security_group_id = aws_security_group.vmray_server_sg.id
  99. security_group_id = aws_security_group.vmray_worker_sg.id
  100. }
  101. resource "aws_security_group_rule" "vmray_worker_https_to_server" {
  102. type = "egress"
  103. from_port = 443
  104. to_port = 443
  105. protocol = "tcp"
  106. source_security_group_id = aws_security_group.vmray_server_sg.id
  107. security_group_id = aws_security_group.vmray_worker_sg.id
  108. }