securitygroup-server.tf 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # SG Summary - Server
  2. # Ingress:
  3. # 22 - sync from other security centers
  4. # 443 - User access
  5. # Egress:
  6. # 25 - smtp
  7. # 443 - updates
  8. # tcp/1243 - "Communicating with Log Correlation Engine" (unneeded in xdr)
  9. # tcp/8834-8835 - Communicating With Nessus - to vpc-scanners
  10. resource "aws_security_group" "nessus_scanner" {
  11. name_prefix = "nessus_scanner"
  12. tags = merge(local.standard_tags, var.tags, { Name = "nessus_scanner" })
  13. vpc_id = var.vpc_id
  14. description = "Nessus Security Scanner"
  15. }
  16. #-----------------------------------------------------------------
  17. # Ingress
  18. #-----------------------------------------------------------------
  19. resource "aws_security_group_rule" "nessus_scanner_inbound_icmp" {
  20. security_group_id = aws_security_group.nessus_scanner.id
  21. type = "ingress"
  22. description = "Inbound pings"
  23. cidr_blocks = ["10.0.0.0/8"]
  24. from_port = -1
  25. to_port = -1
  26. protocol = "ICMP"
  27. }
  28. resource "aws_security_group_rule" "nessus_scanner_inbound_22" {
  29. security_group_id = aws_security_group.nessus_scanner.id
  30. type = "ingress"
  31. description = "SSH - Inbound (from access)"
  32. cidr_blocks = toset(concat(local.cidr_map["vpc-access"], local.cidr_map["vpc-private-services"]))
  33. from_port = 22
  34. to_port = 22
  35. protocol = "tcp"
  36. }
  37. resource "aws_security_group_rule" "nessus_scanner_inbound_3022" {
  38. security_group_id = aws_security_group.nessus_scanner.id
  39. type = "ingress"
  40. description = "Inbound teleport (from access)"
  41. cidr_blocks = local.cidr_map["vpc-access"]
  42. from_port = 3022
  43. to_port = 3022
  44. protocol = "tcp"
  45. }
  46. resource "aws_security_group_rule" "nessus_scanner_inbound_443" {
  47. security_group_id = aws_security_group.nessus_scanner.id
  48. type = "ingress"
  49. description = "443 - Inbound (from access)"
  50. cidr_blocks = toset(concat(local.cidr_map["vpc-access"], local.cidr_map["vpc-private-services"]))
  51. from_port = 443
  52. to_port = 443
  53. protocol = "tcp"
  54. }
  55. resource "aws_security_group_rule" "nessus_scanner_inbound_nessus" {
  56. security_group_id = aws_security_group.nessus_scanner.id
  57. type = "ingress"
  58. description = "Inbound Nessus"
  59. cidr_blocks = toset(concat(local.cidr_map["vpc-access"], local.cidr_map["vpc-private-services"]))
  60. from_port = 8834
  61. to_port = 8835
  62. protocol = "tcp"
  63. }
  64. resource "aws_security_group_rule" "nessus_scanner_inbound_scan_ourselves" {
  65. security_group_id = aws_security_group.nessus_scanner.id
  66. source_security_group_id = aws_security_group.nessus_scanner.id
  67. type = "ingress"
  68. from_port = -1
  69. to_port = -1
  70. protocol = "all"
  71. description = "Inbound Scanning of Ourselves"
  72. }
  73. #-----------------------------------------------------------------
  74. # Egress
  75. #-----------------------------------------------------------------
  76. resource "aws_security_group_rule" "nessus_scanner_outbound_all_ports" {
  77. security_group_id = aws_security_group.nessus_scanner.id
  78. type = "egress"
  79. description = "Outbound to All Ports"
  80. cidr_blocks = ["0.0.0.0/0"] # tfsec:ignore:aws-vpc-no-public-egress-sgr
  81. from_port = -1
  82. to_port = -1
  83. protocol = "all"
  84. }