securitygroups-load-balancers.tf 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. allowed_sources = ["0.0.0.0/0"]
  28. }
  29. #----------------------------------------------------------------
  30. # SG for the Internal ELB
  31. #----------------------------------------------------------------
  32. resource "aws_security_group" "ghe_elb_internal" {
  33. # checkov:skip=CKV2_AWS_5: attached to GHE Internal ELB
  34. name_prefix = "ghe_elb_internal"
  35. tags = merge(local.standard_tags, var.tags, { Name = "github-internal-lb" })
  36. vpc_id = var.vpc_id
  37. description = "Internal ELB for GitHub Enterprise Server"
  38. }
  39. #-----------------------------------------------------------------
  40. # INGRESS
  41. #-----------------------------------------------------------------
  42. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_cidr" {
  43. security_group_id = aws_security_group.ghe_elb_internal.id
  44. type = "ingress"
  45. description = "HTTPS - Inbound"
  46. cidr_blocks = ["10.0.0.0/8"]
  47. from_port = 443
  48. to_port = 443
  49. protocol = "tcp"
  50. }
  51. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_8443_cidr" {
  52. security_group_id = aws_security_group.ghe_elb_internal.id
  53. type = "ingress"
  54. description = "HTTPS 8443 - Inbound"
  55. cidr_blocks = ["10.0.0.0/8"]
  56. from_port = 8443
  57. to_port = 8443
  58. protocol = "tcp"
  59. }
  60. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_22_cidr" {
  61. security_group_id = aws_security_group.ghe_elb_internal.id
  62. type = "ingress"
  63. description = "Inbound git"
  64. cidr_blocks = ["10.0.0.0/8"]
  65. from_port = 22
  66. to_port = 22
  67. protocol = "tcp"
  68. }
  69. #-----------------------------------------------------------------
  70. # INGRESS
  71. #-----------------------------------------------------------------
  72. # Let the ELB talk to the github server(s)
  73. resource "aws_security_group_rule" "ghe_elb_internal_outbound_https" {
  74. security_group_id = aws_security_group.ghe_elb_internal.id
  75. type = "egress"
  76. description = "HTTPS - Outbound from ELB to GH Servers"
  77. source_security_group_id = aws_security_group.ghe_server.id
  78. from_port = 443
  79. to_port = 443
  80. protocol = "tcp"
  81. }
  82. # Let the ELB talk to the github server(s)
  83. resource "aws_security_group_rule" "ghe_elb_internal_outbound_8444_https" {
  84. security_group_id = aws_security_group.ghe_elb_internal.id
  85. type = "egress"
  86. description = "HTTPS 8443 - Outbound from ELB to GH Servers"
  87. source_security_group_id = aws_security_group.ghe_server.id
  88. from_port = 8443
  89. to_port = 8444
  90. protocol = "tcp"
  91. }
  92. resource "aws_security_group_rule" "ghe_elb_internal_outbound_23_https" {
  93. security_group_id = aws_security_group.ghe_elb_internal.id
  94. type = "egress"
  95. description = "HTTPS 23 - Outbound from ELB to GH Servers"
  96. source_security_group_id = aws_security_group.ghe_server.id
  97. from_port = 23
  98. to_port = 23
  99. protocol = "tcp"
  100. }