github_servers.tf 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Rather than pass in the aws security group, we just look it up. This will
  2. # probably be useful other places, as well.
  3. data "aws_security_group" "typical-host" {
  4. name = "typical-host"
  5. vpc_id = var.vpc_id
  6. }
  7. # Use the default EBS key
  8. data "aws_kms_key" "ebs-key" {
  9. key_id = "alias/ebs_root_encrypt_decrypt"
  10. }
  11. resource "aws_instance" "ghe" {
  12. count = local.instance_count
  13. ami = aws_ami_copy.github.id
  14. instance_type = var.environment == "prod" ? "c5.4xlarge" : "r5a.4xlarge"
  15. subnet_id = var.private_subnets[count.index]
  16. vpc_security_group_ids = [data.aws_security_group.typical-host.id, aws_security_group.ghe_server.id]
  17. associate_public_ip_address = false
  18. ebs_optimized = true
  19. tenancy = "default"
  20. disable_api_termination = var.instance_termination_protection
  21. instance_initiated_shutdown_behavior = "stop"
  22. key_name = "msoc-build"
  23. monitoring = false # checkov:skip=CKV_AWS_126:Detailed monitoring not needed at this time
  24. iam_instance_profile = module.instance_profile.profile_id
  25. metadata_options {
  26. http_endpoint = "enabled"
  27. http_tokens = "required"
  28. }
  29. # single space to disable default module behavior
  30. root_block_device {
  31. volume_size = 200
  32. volume_type = "gp3"
  33. iops = 3000
  34. delete_on_termination = true
  35. encrypted = true
  36. kms_key_id = data.aws_kms_key.ebs-key.arn
  37. }
  38. ebs_block_device {
  39. # github data
  40. # Note: Not in AMI
  41. device_name = "/dev/xvdf"
  42. volume_size = 500
  43. delete_on_termination = true
  44. encrypted = true
  45. kms_key_id = data.aws_kms_key.ebs-key.arn
  46. volume_type = "gp3"
  47. iops = 3000
  48. }
  49. tags = merge(local.standard_tags, var.tags, var.instance_tags, { Name = format("%s-%s", "github-enterprise", count.index) })
  50. volume_tags = merge(local.standard_tags, var.tags, { Name = format("%s-%s", "github-enterprise", count.index) })
  51. }
  52. # Would need this a second time if count > 0
  53. module "private_dns_record_ghe_backup_0" {
  54. source = "../../submodules/dns/private_A_record"
  55. name = format("%s-%s", "github-enterprise", 0)
  56. ip_addresses = [aws_instance.ghe[0].private_ip]
  57. dns_info = var.dns_info
  58. reverse_enabled = var.reverse_enabled
  59. providers = {
  60. aws.c2 = aws.c2
  61. }
  62. }