main.tf 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. resource "random_id" "random" {
  2. byte_length = 20
  3. }
  4. ################################################################################
  5. ### Hybrid account
  6. ################################################################################
  7. # Ignoring tfsec issues within the third party module:
  8. # TODO: Revisit these
  9. # tfsec:ignore:aws-vpc-no-public-egress-sgr
  10. # tfsec:ignore:aws-sqs-enable-queue-encryption
  11. # tfsec:ignore:aws-s3-encryption-customer-key
  12. # tfsec:ignore:aws-s3-enable-bucket-encryption
  13. # tfsec:ignore:aws-autoscaling-enforce-http-token-imds
  14. # tfsec:ignore:aws-s3-enable-versioning
  15. # tfsec:ignore:aws-api-gateway-enable-access-logging
  16. module "runners" {
  17. source = "../../thirdparty/terraform-aws-github-runner"
  18. create_service_linked_role_spot = false
  19. aws_partition = var.aws_partition
  20. aws_region = var.aws_region
  21. vpc_id = var.vpc_id
  22. subnet_ids = var.public_subnets # should these be private?
  23. ghes_url = local.ghes_url
  24. prefix = lower("${var.org}-github-runners")
  25. tags = merge(local.standard_tags, var.tags, { org = var.org })
  26. github_app = {
  27. key_base64 = local.webhook_key
  28. id = var.github_app_id
  29. webhook_secret = random_id.random.hex
  30. }
  31. # Spot or on-demand
  32. instance_target_capacity_type = "spot"
  33. # configure the block device mappings, default for Amazon Linux2
  34. block_device_mappings = [{
  35. device_name = "/dev/xvda"
  36. delete_on_termination = true
  37. volume_type = "gp3"
  38. volume_size = 10
  39. encrypted = true
  40. iops = null
  41. }]
  42. lambda_s3_bucket = "afsxdr-binaries"
  43. webhook_lambda_s3_key = "terraform-aws-github/webhook.zip"
  44. syncer_lambda_s3_key = "terraform-aws-github/runner-binaries-syncer.zip"
  45. runners_lambda_s3_key = "terraform-aws-github/runners.zip"
  46. enable_organization_runners = true
  47. runner_extra_labels = "default"
  48. role_path = "/lambda/"
  49. instance_profile_path = "/lambda/"
  50. # enable access to the runners via SSM
  51. enable_ssm_on_runners = true
  52. # use S3 or KMS SSE to runners S3 bucket
  53. runner_binaries_s3_sse_configuration = {
  54. rule = {
  55. apply_server_side_encryption_by_default = {
  56. sse_algorithm = "AES256"
  57. }
  58. }
  59. }
  60. # Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
  61. # idle_config = [{
  62. # cron = "* * 9-17 * * *"
  63. # timeZone = "Europe/Amsterdam"
  64. # idleCount = 1
  65. # }]
  66. # Let the module manage the service linked role
  67. # create_service_linked_role_spot = true
  68. instance_types = ["m5a.large", "c5a.large"]
  69. # override delay of events in seconds
  70. delay_webhook_event = 5
  71. runners_maximum_count = 1
  72. # set up a fifo queue to remain order
  73. fifo_build_queue = true
  74. # override scaling down
  75. #scale_down_schedule_expression = "cron(* * * * ? *)"
  76. }