security-groups.tf 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_https_in" {
  13. type = "ingress"
  14. from_port = 443
  15. to_port = 443
  16. protocol = "tcp"
  17. cidr_blocks = var.cidr_map["vpc-access"]
  18. security_group_id = aws_security_group.vmray_server_sg.id
  19. }
  20. # Proxy? Ubuntu doesn't have it configured yet
  21. resource "aws_security_group_rule" "vmray_server_http_out" {
  22. type = "egress"
  23. from_port = 80
  24. to_port = 80
  25. protocol = "tcp"
  26. cidr_blocks = [ "0.0.0.0/0" ]
  27. security_group_id = aws_security_group.vmray_server_sg.id
  28. }
  29. resource "aws_security_group_rule" "vmray_server_https_out" {
  30. type = "egress"
  31. from_port = 443
  32. to_port = 443
  33. protocol = "tcp"
  34. cidr_blocks = [ "0.0.0.0/0" ]
  35. security_group_id = aws_security_group.vmray_server_sg.id
  36. }
  37. resource "aws_security_group_rule" "vmray_server_vnc_to_workers" {
  38. type = "egress"
  39. from_port = 5900
  40. to_port = 5999
  41. protocol = "tcp"
  42. source_security_group_id = aws_security_group.vmray_worker_sg.id
  43. security_group_id = aws_security_group.vmray_server_sg.id
  44. }
  45. # Workers
  46. resource "aws_security_group" "vmray_worker_sg" {
  47. name = "vmray_worker_sg"
  48. description = "Security Rules for the VMRay Worker Nodes"
  49. vpc_id = var.vpc_id
  50. tags = merge(var.standard_tags, var.tags)
  51. }
  52. resource "aws_security_group_rule" "vmwary_worker_vnc_from_server" {
  53. type = "ingress"
  54. from_port = 5900
  55. to_port = 5999
  56. protocol = "tcp"
  57. source_security_group_id = aws_security_group.vmray_server_sg.id
  58. security_group_id = aws_security_group.vmray_worker_sg.id
  59. }
  60. resource "aws_security_group_rule" "vmray_worker_http_out" {
  61. type = "egress"
  62. from_port = 80
  63. to_port = 80
  64. protocol = "tcp"
  65. cidr_blocks = [ "0.0.0.0/0" ]
  66. security_group_id = aws_security_group.vmray_worker_sg.id
  67. }
  68. resource "aws_security_group_rule" "vmray_worker_https_out" {
  69. type = "egress"
  70. from_port = 443
  71. to_port = 443
  72. protocol = "tcp"
  73. cidr_blocks = [ "0.0.0.0/0" ]
  74. security_group_id = aws_security_group.vmray_worker_sg.id
  75. }
  76. resource "aws_security_group_rule" "vmray_worker_http_to_server" {
  77. type = "egress"
  78. from_port = 80
  79. to_port = 80
  80. protocol = "tcp"
  81. source_security_group_id = aws_security_group.vmray_server_sg.id
  82. security_group_id = aws_security_group.vmray_worker_sg.id
  83. }
  84. resource "aws_security_group_rule" "vmray_worker_https_to_server" {
  85. type = "egress"
  86. from_port = 443
  87. to_port = 443
  88. protocol = "tcp"
  89. source_security_group_id = aws_security_group.vmray_server_sg.id
  90. security_group_id = aws_security_group.vmray_worker_sg.id
  91. }