securitygroup-server.tf 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # SG Summary - Server
  2. # Inbound::
  3. # tcp/8888 - from 10.0.0.0/8
  4. # tcp/443 - from load balancers, vpc-access (legacy was from 10.0.0.0/8)
  5. #
  6. # Outbound:
  7. # tcp/8089 - 10.0.0.0/8 (splunk)
  8. # udp/53 - 0.0.0.0/0 (dns for oscontext)
  9. # DISABLED tcp/464 - 10.80.0.0/16 (legacy vpc)
  10. # DISABLED tcp/636 - 0.0.0.0/0 (LDAPS outbound)
  11. # DISABLED tcp/389 - 10.80.0.0/16 (legacy vpc)
  12. # DISABLED tcp+udp/88 - 10.80.0.0/16 (idm)
  13. #
  14. # New:
  15. resource "aws_security_group" "phantom_server" {
  16. name_prefix = "phantom_server"
  17. tags = merge( var.standard_tags, var.tags, { Name = "phantom_server" } )
  18. vpc_id = var.vpc_id
  19. description = "Phantom Server"
  20. }
  21. #-----------------------------------------------------------------
  22. # Inbound access
  23. #-----------------------------------------------------------------
  24. resource "aws_security_group_rule" "phantom_server_inbound_8888" {
  25. security_group_id = aws_security_group.phantom_server.id
  26. type = "ingress"
  27. cidr_blocks = [ "10.0.0.0/8" ]
  28. from_port = 8888
  29. to_port = 8888
  30. protocol = "tcp"
  31. description = "Inbound 8888 - Phantom Websocket"
  32. }
  33. resource "aws_security_group_rule" "phantom_server_inbound_alb_443" {
  34. security_group_id = aws_security_group.phantom_server.id
  35. type = "ingress"
  36. source_security_group_id = aws_security_group.phantom_alb_internal.id
  37. from_port = 443
  38. to_port = 443
  39. protocol = "tcp"
  40. description = "Inbound 443 (from load balancers)"
  41. }
  42. resource "aws_security_group_rule" "phantom_server_inbound_alb_443_from_vpn" {
  43. security_group_id = aws_security_group.phantom_server.id
  44. type = "ingress"
  45. cidr_blocks = var.cidr_map["vpc-access"]
  46. from_port = 443
  47. to_port = 443
  48. protocol = "tcp"
  49. description = "Inbound 443 (from load access, for troubleshooting)"
  50. }
  51. #-----------------------------------------------------------------
  52. # Outbound access
  53. #-----------------------------------------------------------------
  54. resource "aws_security_group_rule" "phantom_server_outbound_postgres" {
  55. security_group_id = aws_security_group.phantom_server.id
  56. type = "egress"
  57. cidr_blocks = [ "10.0.0.0/8" ]
  58. from_port = 8089
  59. to_port = 8089
  60. protocol = "tcp"
  61. description = "Outbound to splunk everywhere"
  62. }
  63. resource "aws_security_group_rule" "phantom_server_outbound_udp_dns" {
  64. security_group_id = aws_security_group.phantom_server.id
  65. type = "egress"
  66. cidr_blocks = [ "0.0.0.0/0" ]
  67. from_port = 53
  68. to_port = 53
  69. protocol = "tcp"
  70. description = "Outbound tcp dns anywhere"
  71. }
  72. resource "aws_security_group_rule" "phantom_server_outbound_tcp_dns" {
  73. security_group_id = aws_security_group.phantom_server.id
  74. type = "egress"
  75. cidr_blocks = [ "0.0.0.0/0" ]
  76. from_port = 53
  77. to_port = 53
  78. protocol = "udp"
  79. description = "Outbound udp dns anywhere"
  80. }
  81. resource "aws_security_group_rule" "phantom_server_outbound_http" {
  82. security_group_id = aws_security_group.phantom_server.id
  83. type = "egress"
  84. cidr_blocks = [ "0.0.0.0/0" ]
  85. from_port = 80
  86. to_port = 80
  87. protocol = "tcp"
  88. description = "Outbound http anywhere (required for saleforce and others)"
  89. }
  90. resource "aws_security_group_rule" "phantom_server_outbound_https" {
  91. security_group_id = aws_security_group.phantom_server.id
  92. type = "egress"
  93. cidr_blocks = [ "0.0.0.0/0" ]
  94. from_port = 443
  95. to_port = 443
  96. protocol = "tcp"
  97. description = "Outbound https anywhere (required for saleforce and others)"
  98. }
  99. resource "aws_security_group_rule" "phantom_server_outbound_ssh_to_legacy" {
  100. security_group_id = aws_security_group.phantom_server.id
  101. type = "egress"
  102. cidr_blocks = var.environment == "prod" ? [ "10.80.101.221/32" ] : [ "10.96.101.186/32" ]
  103. from_port = 22
  104. to_port = 22
  105. protocol = "tcp"
  106. description = "Outbound ssh to legacy. Remove after migration."
  107. }