|
1 | 1 | locals {
|
2 | 2 | environment = var.environment != null ? var.environment : "multi-runner"
|
3 | 3 | aws_region = "eu-west-1"
|
| 4 | + |
| 5 | + # Load runner configurations from Yaml files |
| 6 | + multi_runner_config = { for c in fileset("${path.module}/templates/runner-configs", "*.yaml") : trimsuffix(c, ".yaml") => yamldecode(file("${path.module}/templates/runner-configs/${c}")) } |
4 | 7 | }
|
5 | 8 |
|
6 | 9 | resource "random_id" "random" {
|
7 | 10 | byte_length = 20
|
8 | 11 | }
|
9 | 12 |
|
10 | 13 | module "multi-runner" {
|
11 |
| - source = "../../modules/multi-runner" |
12 |
| - multi_runner_config = { |
13 |
| - "linux-arm64" = { |
14 |
| - matcherConfig : { |
15 |
| - labelMatchers = [["self-hosted", "linux", "arm64", "amazon"]] |
16 |
| - exactMatch = true |
17 |
| - } |
18 |
| - fifo = true |
19 |
| - delay_webhook_event = 0 |
20 |
| - redrive_build_queue = { |
21 |
| - enabled = false |
22 |
| - maxReceiveCount = null |
23 |
| - } |
24 |
| - runner_config = { |
25 |
| - runner_os = "linux" |
26 |
| - runner_architecture = "arm64" |
27 |
| - runner_extra_labels = "amazon" |
28 |
| - runner_name_prefix = "amazon-arm64_" |
29 |
| - enable_ssm_on_runners = true |
30 |
| - instance_types = ["t4g.large", "c6g.large"] |
31 |
| - runners_maximum_count = 1 |
32 |
| - scale_down_schedule_expression = "cron(* * * * ? *)" |
33 |
| - } |
34 |
| - }, |
35 |
| - "linux-ubuntu" = { |
36 |
| - matcherConfig : { |
37 |
| - labelMatchers = [["self-hosted", "linux", "x64", "ubuntu-latest"], ["self-hosted", "linux", "x64", "ubuntu-2204"]] |
38 |
| - exactMatch = true |
39 |
| - } |
40 |
| - fifo = true |
41 |
| - delay_webhook_event = 0 |
42 |
| - redrive_build_queue = { |
43 |
| - enabled = false |
44 |
| - maxReceiveCount = null |
45 |
| - } |
46 |
| - runner_config = { |
47 |
| - runner_os = "linux" |
48 |
| - runner_architecture = "x64" |
49 |
| - runner_extra_labels = "ubuntu-latest,ubuntu-2204" |
50 |
| - runner_run_as = "ubuntu" |
51 |
| - runner_name_prefix = "ubuntu-2204-x64_" |
52 |
| - enable_ssm_on_runners = true |
53 |
| - instance_types = ["m5ad.large", "m5a.large"] |
54 |
| - runners_maximum_count = 1 |
55 |
| - scale_down_schedule_expression = "cron(* * * * ? *)" |
56 |
| - userdata_template = "./templates/user-data.sh" |
57 |
| - ami_owners = ["099720109477"] # Canonical's Amazon account ID |
58 |
| - |
59 |
| - ami_filter = { |
60 |
| - name = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] |
61 |
| - } |
62 |
| - block_device_mappings = [{ |
63 |
| - # Set the block device name for Ubuntu root device |
64 |
| - device_name = "/dev/sda1" |
65 |
| - delete_on_termination = true |
66 |
| - volume_type = "gp3" |
67 |
| - volume_size = 30 |
68 |
| - encrypted = true |
69 |
| - iops = null |
70 |
| - throughput = null |
71 |
| - kms_key_id = null |
72 |
| - snapshot_id = null |
73 |
| - }] |
74 |
| - runner_log_files = [ |
75 |
| - { |
76 |
| - log_group_name = "syslog" |
77 |
| - prefix_log_group = true |
78 |
| - file_path = "/var/log/syslog" |
79 |
| - log_stream_name = "{instance_id}" |
80 |
| - }, |
81 |
| - { |
82 |
| - log_group_name = "user_data" |
83 |
| - prefix_log_group = true |
84 |
| - file_path = "/var/log/user-data.log" |
85 |
| - log_stream_name = "{instance_id}/user_data" |
86 |
| - }, |
87 |
| - { |
88 |
| - log_group_name = "runner" |
89 |
| - prefix_log_group = true |
90 |
| - file_path = "/opt/actions-runner/_diag/Runner_**.log", |
91 |
| - log_stream_name = "{instance_id}/runner" |
92 |
| - } |
93 |
| - ] |
94 |
| - } |
95 |
| - }, |
96 |
| - "windows-x64" = { |
97 |
| - matcherConfig : { |
98 |
| - labelMatchers = [["self-hosted", "windows", "x64", "servercore-2022"]] |
99 |
| - exactMatch = true |
100 |
| - } |
101 |
| - fifo = true |
102 |
| - delay_webhook_event = 5 |
103 |
| - runner_config = { |
104 |
| - runner_os = "windows" |
105 |
| - runner_architecture = "x64" |
106 |
| - runner_name_prefix = "servercore-2022-x64_" |
107 |
| - enable_ssm_on_runners = true |
108 |
| - instance_types = ["m5.large", "c5.large"] |
109 |
| - runner_extra_labels = "servercore-2022" |
110 |
| - runners_maximum_count = 1 |
111 |
| - scale_down_schedule_expression = "cron(* * * * ? *)" |
112 |
| - runner_boot_time_in_minutes = 20 |
113 |
| - ami_filter = { |
114 |
| - name = ["Windows_Server-2022-English-Core-ContainersLatest-*"] |
115 |
| - } |
116 |
| - } |
117 |
| - }, |
118 |
| - "linux-x64" = { |
119 |
| - matcherConfig : { |
120 |
| - labelMatchers = [["self-hosted", "linux", "x64", "amazon"]] |
121 |
| - exactMatch = false |
122 |
| - } |
123 |
| - fifo = true |
124 |
| - delay_webhook_event = 0 |
125 |
| - runner_config = { |
126 |
| - # Test retrieving tag information via AWS API (Cli) |
127 |
| - runner_metadata_options = { |
128 |
| - instance_metadata_tags = "disabled" |
129 |
| - http_endpoint = "enabled" |
130 |
| - http_tokens = "optional" |
131 |
| - http_put_response_hop_limit = 1 |
132 |
| - } |
133 |
| - runner_os = "linux" |
134 |
| - runner_architecture = "x64" |
135 |
| - runner_name_prefix = "amazon-x64_" |
136 |
| - create_service_linked_role_spot = true |
137 |
| - enable_ssm_on_runners = true |
138 |
| - instance_types = ["m5ad.large", "m5a.large"] |
139 |
| - runner_extra_labels = "amazon" |
140 |
| - runners_maximum_count = 1 |
141 |
| - enable_ephemeral_runners = true |
142 |
| - scale_down_schedule_expression = "cron(* * * * ? *)" |
143 |
| - } |
144 |
| - } |
145 |
| - } |
| 14 | + source = "../../modules/multi-runner" |
| 15 | + multi_runner_config = local.multi_runner_config |
| 16 | + # Alternative to loading runner configuration from Yaml files is using static configuration: |
| 17 | + # multi_runner_config = { |
| 18 | + # "linux-x64" = { |
| 19 | + # matcherConfig : { |
| 20 | + # labelMatchers = [["self-hosted", "linux", "x64", "amazon"]] |
| 21 | + # exactMatch = false |
| 22 | + # } |
| 23 | + # fifo = true |
| 24 | + # delay_webhook_event = 0 |
| 25 | + # runner_config = { |
| 26 | + # runner_os = "linux" |
| 27 | + # runner_architecture = "x64" |
| 28 | + # runner_name_prefix = "amazon-x64_" |
| 29 | + # create_service_linked_role_spot = true |
| 30 | + # enable_ssm_on_runners = true |
| 31 | + # instance_types = ["m5ad.large", "m5a.large"] |
| 32 | + # runner_extra_labels = "amazon" |
| 33 | + # runners_maximum_count = 1 |
| 34 | + # enable_ephemeral_runners = true |
| 35 | + # scale_down_schedule_expression = "cron(* * * * ? *)" |
| 36 | + # } |
| 37 | + # } |
| 38 | + # } |
146 | 39 | aws_region = local.aws_region
|
147 | 40 | vpc_id = module.vpc.vpc_id
|
148 | 41 | subnet_ids = module.vpc.private_subnets
|
|
0 commit comments