github_servers.tf 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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
  24. iam_instance_profile = module.instance_profile.profile_id
  25. metadata_options {
  26. http_tokens = "required"
  27. }
  28. # single space to disable default module behavior
  29. root_block_device {
  30. volume_size = 200
  31. volume_type = "gp3"
  32. iops = 3000
  33. delete_on_termination = true
  34. encrypted = true
  35. kms_key_id = data.aws_kms_key.ebs-key.arn
  36. }
  37. ebs_block_device {
  38. # github data
  39. # Note: Not in AMI
  40. device_name = "/dev/xvdf"
  41. volume_size = 500
  42. delete_on_termination = true
  43. encrypted = true
  44. kms_key_id = data.aws_kms_key.ebs-key.arn
  45. volume_type = "gp3"
  46. iops = 3000
  47. }
  48. tags = merge(local.standard_tags, var.tags, var.instance_tags, { Name = format("%s-%s", "github-enterprise", count.index) })
  49. volume_tags = merge(local.standard_tags, var.tags, { Name = format("%s-%s", "github-enterprise", count.index) })
  50. }
  51. # Would need this a second time if count > 0
  52. module "private_dns_record_ghe_backup_0" {
  53. source = "../../submodules/dns/private_A_record"
  54. name = format("%s-%s", "github-enterprise", 0)
  55. ip_addresses = [aws_instance.ghe[0].private_ip]
  56. dns_info = var.dns_info
  57. reverse_enabled = var.reverse_enabled
  58. providers = {
  59. aws.c2 = aws.c2
  60. }
  61. }