github_servers.tf 2.1 KB

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