securitygroups-load-balancers.tf 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #----------------------------------------------------------------
  2. # SG for the external ELB
  3. #----------------------------------------------------------------
  4. locals {
  5. # from https://config.zscaler.com/zscalergov.net/cenr
  6. zscalar_cidrs = [
  7. "165.225.3.0/24",
  8. "136.226.10.0/23",
  9. "136.226.12.0/23",
  10. "136.226.14.0/23",
  11. "165.225.46.0/24",
  12. "136.226.6.0/23",
  13. "136.226.4.0/23",
  14. "136.226.8.0/23",
  15. "136.226.22.0/24",
  16. "165.225.48.0/24",
  17. "136.226.18.0/23",
  18. "136.226.16.0/23",
  19. "136.226.20.0/23",
  20. ]
  21. salt_masters = [
  22. "18.253.198.129/32", # Salt Master Prod - proxy
  23. "18.253.73.251/32", # salt master prod
  24. "18.252.61.81/32", # Salt master dev - proxy
  25. "18.253.226.199/32", # salt aster dev
  26. ]
  27. # Locking down sources on 2021-12-10 due to log4j vulnerability
  28. #allowed_sources = local.zscalar_cidrs
  29. #allowed_sources = concat(local.trusted_ips, local.zscalar_cidrs)
  30. #allowed_sources = concat(local.zscalar_cidrs, local.trusted_ips, local.salt_masters)
  31. # Restored access on 2021-12-14
  32. allowed_sources = ["0.0.0.0/0"]
  33. }
  34. #----------------------------------------------------------------
  35. # SG for the Internal ELB
  36. #----------------------------------------------------------------
  37. resource "aws_security_group" "ghe_elb_internal" {
  38. # checkov:skip=CKV2_AWS_5: attached to GHE Internal ELB
  39. name_prefix = "ghe_elb_internal"
  40. tags = merge(local.standard_tags, var.tags, { Name = "github-internal-lb" })
  41. vpc_id = var.vpc_id
  42. description = "Internal ELB for GitHub Enterprise Server"
  43. }
  44. #-----------------------------------------------------------------
  45. # INGRESS
  46. #-----------------------------------------------------------------
  47. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_cidr" {
  48. security_group_id = aws_security_group.ghe_elb_internal.id
  49. type = "ingress"
  50. description = "HTTPS - Inbound"
  51. cidr_blocks = ["10.0.0.0/8"]
  52. from_port = 443
  53. to_port = 443
  54. protocol = "tcp"
  55. }
  56. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_8443_cidr" {
  57. security_group_id = aws_security_group.ghe_elb_internal.id
  58. type = "ingress"
  59. description = "HTTPS 8443 - Inbound"
  60. cidr_blocks = ["10.0.0.0/8"]
  61. from_port = 8443
  62. to_port = 8443
  63. protocol = "tcp"
  64. }
  65. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_22_cidr" {
  66. security_group_id = aws_security_group.ghe_elb_internal.id
  67. type = "ingress"
  68. description = "Inbound git"
  69. cidr_blocks = ["10.0.0.0/8"]
  70. from_port = 22
  71. to_port = 22
  72. protocol = "tcp"
  73. }
  74. #-----------------------------------------------------------------
  75. # INGRESS
  76. #-----------------------------------------------------------------
  77. # Let the ELB talk to the github server(s)
  78. resource "aws_security_group_rule" "ghe_elb_internal_outbound_https" {
  79. security_group_id = aws_security_group.ghe_elb_internal.id
  80. type = "egress"
  81. description = "HTTPS - Outbound from ELB to GH Servers"
  82. source_security_group_id = aws_security_group.ghe_server.id
  83. from_port = 443
  84. to_port = 443
  85. protocol = "tcp"
  86. }
  87. # Let the ELB talk to the github server(s)
  88. resource "aws_security_group_rule" "ghe_elb_internal_outbound_8444_https" {
  89. security_group_id = aws_security_group.ghe_elb_internal.id
  90. type = "egress"
  91. description = "HTTPS 8443 - Outbound from ELB to GH Servers"
  92. source_security_group_id = aws_security_group.ghe_server.id
  93. from_port = 8443
  94. to_port = 8444
  95. protocol = "tcp"
  96. }
  97. resource "aws_security_group_rule" "ghe_elb_internal_outbound_23_https" {
  98. security_group_id = aws_security_group.ghe_elb_internal.id
  99. type = "egress"
  100. description = "HTTPS 23 - Outbound from ELB to GH Servers"
  101. source_security_group_id = aws_security_group.ghe_server.id
  102. from_port = 23
  103. to_port = 23
  104. protocol = "tcp"
  105. }