securitygroups-load-balancers.tf 3.7 KB

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