securitygroup-server.tf 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. # SG Summary - Server
  2. #
  3. # 22 - From vpc-access
  4. # 23 - From Load Balancers
  5. # 122 - From vpc-access, ghe-backup
  6. # 443-444 - From Load Balancers, vpc-access
  7. # 8443 - From vpc-access, GHE-Backup
  8. # 8444 - From Load Balancers
  9. #
  10. resource "aws_security_group" "ghe_server" {
  11. name_prefix = "ghe_server"
  12. tags = merge( var.standard_tags, var.tags, { Name = "github-enterprise-server" } )
  13. vpc_id = var.vpc_id
  14. description = "GitHub Enterprise Servers and Backup Servers"
  15. }
  16. #-----------------------------------------------------------------
  17. # Inbound access
  18. #-----------------------------------------------------------------
  19. resource "aws_security_group_rule" "ghe_server_inbound_ssh_cidr" {
  20. security_group_id = aws_security_group.ghe_server.id
  21. type = "ingress"
  22. cidr_blocks = var.cidr_map["vpc-access"]
  23. from_port = 22
  24. to_port = 22
  25. protocol = "tcp"
  26. description = "Inbound ssh (for git)"
  27. }
  28. resource "aws_security_group_rule" "ghe_server_inbound_https_external_elb_23" {
  29. security_group_id = aws_security_group.ghe_server.id
  30. source_security_group_id = aws_security_group.ghe_elb_external.id
  31. type = "ingress"
  32. from_port = 23
  33. to_port = 23
  34. protocol = "tcp"
  35. description = "Inbound tcp/23 from external ELBs"
  36. }
  37. resource "aws_security_group_rule" "ghe_server_inbound_https_internal_elb_23" {
  38. security_group_id = aws_security_group.ghe_server.id
  39. source_security_group_id = aws_security_group.ghe_elb_internal.id
  40. type = "ingress"
  41. from_port = 23
  42. to_port = 23
  43. protocol = "tcp"
  44. description = "Inbound tcp/23 from internal ELBs"
  45. }
  46. resource "aws_security_group_rule" "ghe_server_inbound_mgmt_ssh_cidr" {
  47. security_group_id = aws_security_group.ghe_server.id
  48. type = "ingress"
  49. cidr_blocks = var.cidr_map["vpc-access"]
  50. from_port = 122
  51. to_port = 122
  52. protocol = "tcp"
  53. description = "Inbound ssh (for mgmt)"
  54. }
  55. resource "aws_security_group_rule" "ghe_server_inbound_mgmt_ssh_sgs" {
  56. security_group_id = aws_security_group.ghe_server.id
  57. source_security_group_id = aws_security_group.ghe_server.id
  58. type = "ingress"
  59. from_port = 122
  60. to_port = 122
  61. protocol = "tcp"
  62. description = "Inbound ssh (for mgmt)"
  63. }
  64. resource "aws_security_group_rule" "ghe_server_inbound_mgmt_ssh_backup_sgs" {
  65. security_group_id = aws_security_group.ghe_server.id
  66. source_security_group_id = aws_security_group.ghe_backup_server.id
  67. type = "ingress"
  68. from_port = 122
  69. to_port = 122
  70. protocol = "tcp"
  71. description = "Inbound ssh (for mgmt)"
  72. }
  73. resource "aws_security_group_rule" "ghe_server_inbound_https_cidr" {
  74. security_group_id = aws_security_group.ghe_server.id
  75. type = "ingress"
  76. cidr_blocks = var.cidr_map["vpc-access"]
  77. from_port = 443
  78. to_port = 444
  79. protocol = "tcp"
  80. description = "Inbound https"
  81. }
  82. resource "aws_security_group_rule" "ghe_server_inbound_https_external_elb" {
  83. security_group_id = aws_security_group.ghe_server.id
  84. source_security_group_id = aws_security_group.ghe_elb_external.id
  85. type = "ingress"
  86. from_port = 443
  87. to_port = 444
  88. protocol = "tcp"
  89. description = "Inbound https from external ELBs"
  90. }
  91. resource "aws_security_group_rule" "ghe_server_inbound_https_internal_elb" {
  92. security_group_id = aws_security_group.ghe_server.id
  93. source_security_group_id = aws_security_group.ghe_elb_internal.id
  94. type = "ingress"
  95. from_port = 443
  96. to_port = 444
  97. protocol = "tcp"
  98. description = "Inbound https from internal ELBs"
  99. }
  100. resource "aws_security_group_rule" "ghe_server_inbound_mgmt_https_cidr" {
  101. security_group_id = aws_security_group.ghe_server.id
  102. type = "ingress"
  103. cidr_blocks = var.cidr_map["vpc-access"]
  104. from_port = 8443
  105. to_port = 8443
  106. protocol = "tcp"
  107. description = "Inbound ssh (for mgmt)"
  108. }
  109. resource "aws_security_group_rule" "ghe_server_inbound_mgmt_https_sgs" {
  110. security_group_id = aws_security_group.ghe_server.id
  111. source_security_group_id = aws_security_group.ghe_server.id
  112. type = "ingress"
  113. from_port = 8443
  114. to_port = 8443
  115. protocol = "tcp"
  116. description = "Inbound ssh (for mgmt)"
  117. }
  118. resource "aws_security_group_rule" "ghe_server_inbound_mgmt_https_backup_sgs" {
  119. security_group_id = aws_security_group.ghe_server.id
  120. source_security_group_id = aws_security_group.ghe_backup_server.id
  121. type = "ingress"
  122. from_port = 8443
  123. to_port = 8443
  124. protocol = "tcp"
  125. description = "Inbound ssh (for mgmt)"
  126. }
  127. resource "aws_security_group_rule" "ghe_server_inbound_https_internal_elb_8444" {
  128. security_group_id = aws_security_group.ghe_server.id
  129. source_security_group_id = aws_security_group.ghe_elb_internal.id
  130. type = "ingress"
  131. from_port = 8444
  132. to_port = 8444
  133. protocol = "tcp"
  134. description = "Inbound https/8444 from internal ELBs"
  135. }
  136. resource "aws_security_group_rule" "ghe_server_inbound_https_external_elb_8444" {
  137. security_group_id = aws_security_group.ghe_server.id
  138. source_security_group_id = aws_security_group.ghe_elb_external.id
  139. type = "ingress"
  140. from_port = 8444
  141. to_port = 8444
  142. protocol = "tcp"
  143. description = "Inbound https/8444 from external ELBs"
  144. }
  145. #-----------------------------------------------------------------
  146. # Inbound access
  147. #-----------------------------------------------------------------
  148. resource "aws_security_group_rule" "ghe_server_outbound_syslog" {
  149. security_group_id = aws_security_group.ghe_server.id
  150. type = "egress"
  151. cidr_blocks = var.cidr_map["vpc-splunk"]
  152. from_port = 1514
  153. to_port = 1514
  154. protocol = "tcp"
  155. description = "Outbound syslog"
  156. }