Skip to content

Commit ddc358d

Browse files
authored
Merge pull request #1609 from philips-labs/develop
Release
2 parents 3a71120 + fbd7241 commit ddc358d

File tree

20 files changed

+241
-142
lines changed

20 files changed

+241
-142
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Besides these permissions, the lambdas also need permission to CloudWatch (for l
8383
To be able to support a number of use-cases the module has quite a lot configuration options. We try to choose reasonable defaults. The several examples also shows for the main cases how to configure the runners.
8484

8585
- Org vs Repo level. You can configure the module to connect the runners in GitHub on a org level and share the runners in your org. Or set the runners on repo level. The module will install the runner to the repo. This can be multiple repo's but runners are not shared between repo's.
86-
- Checkrun vs Workflow job event. You can configure the webhook in GitHub to send checkrun or workflow job events to the webhook. Workflow job events are introduced by GitHub in September 2021 and are designed to support scalable runners. We advise when possible to use the workflow job event, you can set `disable_check_wokflow_job_labels = true` to disable the label check.
86+
- Checkrun vs Workflow job event. You can configure the webhook in GitHub to send checkrun or workflow job events to the webhook. Workflow job events are introduced by GitHub in September 2021 and are designed to support scalable runners. We advise when possible to use the workflow job event, you can set `runner_enable_workflow_job_labels_check = true` to let the webhook only accept jobs based on the labels configured. The webhook will check the custom labels provided via the variable `runner_extra_labels` and the GitHub managed labels, "self-hosted", OS and architecture. The OS and architecture are derived from the settings. By default the check is disabled.
8787
- Linux vs Windows. you can configure the os types linux and win. Linux will be used by default.
8888
- Re-use vs Ephemeral. By default runners are re-used for till detected idle, once idle they will be removed from the pool. To improve security we are introducing ephemeral runners. Those runners are only used for one job. Ephemeral runners are only working in combination with the workflow job event. We also suggest to use a pre-build AMI to improve the start time of jobs.
8989
- GitHub cloud vs GitHub enterprise server (GHES). The runner support GitHub cloud as well GitHub enterprise service. For GHES we rely on our community to test and support. We have no possibility to test ourselves on GHES.
@@ -382,7 +382,6 @@ In case the setup does not work as intended follow the trace of events:
382382
| <a name="input_cloudwatch_config"></a> [cloudwatch\_config](#input\_cloudwatch\_config) | (optional) Replaces the module default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details. | `string` | `null` | no |
383383
| <a name="input_create_service_linked_role_spot"></a> [create\_service\_linked\_role\_spot](#input\_create\_service\_linked\_role\_spot) | (optional) create the serviced linked role for spot instances that is required by the scale-up lambda. | `bool` | `false` | no |
384384
| <a name="input_delay_webhook_event"></a> [delay\_webhook\_event](#input\_delay\_webhook\_event) | The number of seconds the event accepted by the webhook is invisible on the queue before the scale up lambda will receive the event. | `number` | `30` | no |
385-
| <a name="input_disable_check_wokflow_job_labels"></a> [disable\_check\_wokflow\_job\_labels](#input\_disable\_check\_wokflow\_job\_labels) | Disable the the check of workflow labels for received workflow job events. | `bool` | `false` | no |
386385
| <a name="input_enable_cloudwatch_agent"></a> [enable\_cloudwatch\_agent](#input\_enable\_cloudwatch\_agent) | Enabling the cloudwatch agent on the ec2 runner instances, the runner contains default config. Configuration can be overridden via `cloudwatch_config`. | `bool` | `true` | no |
387386
| <a name="input_enable_ephemeral_runners"></a> [enable\_ephemeral\_runners](#input\_enable\_ephemeral\_runners) | Enable ephemeral runners, runners will only be used once. | `bool` | `false` | no |
388387
| <a name="input_enable_organization_runners"></a> [enable\_organization\_runners](#input\_enable\_organization\_runners) | Register runners to organization, instead of repo level | `bool` | `false` | no |
@@ -426,7 +425,8 @@ In case the setup does not work as intended follow the trace of events:
426425
| <a name="input_runner_boot_time_in_minutes"></a> [runner\_boot\_time\_in\_minutes](#input\_runner\_boot\_time\_in\_minutes) | The minimum time for an EC2 runner to boot and register as a runner. | `number` | `5` | no |
427426
| <a name="input_runner_ec2_tags"></a> [runner\_ec2\_tags](#input\_runner\_ec2\_tags) | Map of tags that will be added to the launch template instance tag specificatons. | `map(string)` | `{}` | no |
428427
| <a name="input_runner_egress_rules"></a> [runner\_egress\_rules](#input\_runner\_egress\_rules) | List of egress rules for the GitHub runner instances. | <pre>list(object({<br> cidr_blocks = list(string)<br> ipv6_cidr_blocks = list(string)<br> prefix_list_ids = list(string)<br> from_port = number<br> protocol = string<br> security_groups = list(string)<br> self = bool<br> to_port = number<br> description = string<br> }))</pre> | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": null,<br> "from_port": 0,<br> "ipv6_cidr_blocks": [<br> "::/0"<br> ],<br> "prefix_list_ids": null,<br> "protocol": "-1",<br> "security_groups": null,<br> "self": null,<br> "to_port": 0<br> }<br>]</pre> | no |
429-
| <a name="input_runner_extra_labels"></a> [runner\_extra\_labels](#input\_runner\_extra\_labels) | Extra labels for the runners (GitHub). Separate each label by a comma | `string` | `""` | no |
428+
| <a name="input_runner_enable_workflow_job_labels_check"></a> [runner\_enable\_workflow\_job\_labels\_check](#input\_runner\_enable\_workflow\_job\_labels\_check) | If set to true all labels in the workflow job even are matched agaist the custom labels and GitHub labels (os, architecture and `self-hosted`). When the labels are not matching the event is dropped at the webhook. | `bool` | `false` | no |
429+
| <a name="input_runner_extra_labels"></a> [runner\_extra\_labels](#input\_runner\_extra\_labels) | Extra (custom) labels for the runners (GitHub). Separate each label by a comma. Labels checks on the webhook can be enforced by setting `enable_workflow_job_labels_check`. GitHub read-only labels should not be provided. | `string` | `""` | no |
430430
| <a name="input_runner_group_name"></a> [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no |
431431
| <a name="input_runner_iam_role_managed_policy_arns"></a> [runner\_iam\_role\_managed\_policy\_arns](#input\_runner\_iam\_role\_managed\_policy\_arns) | Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role | `list(string)` | `[]` | no |
432432
| <a name="input_runner_log_files"></a> [runner\_log\_files](#input\_runner\_log\_files) | (optional) Replaces the module default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details. | <pre>list(object({<br> log_group_name = string<br> prefix_log_group = bool<br> file_path = string<br> log_stream_name = string<br> }))</pre> | `null` | no |

examples/ephemeral/main.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ module "runners" {
3535
enable_organization_runners = true
3636
runner_extra_labels = "default,example"
3737

38+
# enable workflow labels check
39+
# runner_enable_workflow_job_labels_check = true
40+
3841
# enable access to the runners via SSM
3942
enable_ssm_on_runners = true
4043

@@ -55,12 +58,12 @@ module "runners" {
5558
enable_ephemeral_runners = true
5659

5760
# configure your pre-built AMI
58-
# enabled_userdata = false
59-
# ami_filter = { name = ["github-runner-amzn2-x86_64-2021*"] }
60-
# ami_owners = [data.aws_caller_identity.current.account_id]
61+
enabled_userdata = false
62+
ami_filter = { name = ["github-runner-amzn2-x86_64-2021*"] }
63+
ami_owners = [data.aws_caller_identity.current.account_id]
6164

6265
# Enable logging
63-
# log_level = "debug"
66+
log_level = "debug"
6467

6568
# Setup a dead letter queue, by default scale up lambda will kepp retrying to process event in case of scaling error.
6669
# redrive_policy_build_queue = {

examples/windows/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module "runners" {
3131
runner_extra_labels = "default,example"
3232

3333
# Set the OS to Windows
34-
runner_os = "win"
34+
runner_os = "windows"
3535
# we need to give the runner time to start because this is windows.
3636
runner_boot_time_in_minutes = 20
3737

main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ module "webhook" {
6767
lambda_zip = var.webhook_lambda_zip
6868
lambda_timeout = var.webhook_lambda_timeout
6969
logging_retention_in_days = var.logging_retention_in_days
70-
runner_extra_labels = var.runner_extra_labels
71-
disable_check_wokflow_job_labels = var.disable_check_wokflow_job_labels
70+
71+
# labels
72+
enable_workflow_job_labels_check = var.runner_enable_workflow_job_labels_check
73+
runner_labels = "self-hosted,${var.runner_os},${var.runner_architecture},${var.runner_extra_labels}"
7274

7375
role_path = var.role_path
7476
role_permissions_boundary = var.role_permissions_boundary

modules/runners/lambdas/runners/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"dependencies": {
3737
"@aws-sdk/client-ssm": "^3.45.0",
38-
"@octokit/auth-app": "3.6.0",
38+
"@octokit/auth-app": "3.6.1",
3939
"@octokit/rest": "^18.12.0",
4040
"@octokit/types": "^6.34.0",
4141
"@types/aws-lambda": "^8.10.89",

modules/runners/lambdas/runners/src/scale-runners/scale-down.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ describe('scaleDown', () => {
233233
expiresAt: 'some-date',
234234
permissions: {},
235235
repositorySelection: 'all',
236+
installationId: 0,
236237
});
237238
mockCreateClient.mockResolvedValue(new mocktokit());
238239
DEFAULT_RUNNERS = JSON.parse(JSON.stringify(DEFAULT_RUNNERS_ORIGINAL));

modules/runners/lambdas/runners/src/scale-runners/scale-up.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ beforeEach(() => {
136136
expiresAt: 'some-date',
137137
permissions: {},
138138
repositorySelection: 'all',
139+
installationId: 0,
139140
});
140141

141142
mockCreateClient.mockResolvedValue(new mocktokit());

modules/runners/lambdas/runners/yarn.lock

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,10 +1150,10 @@
11501150
"@nodelib/fs.scandir" "2.1.5"
11511151
fastq "^1.6.0"
11521152

1153-
"@octokit/[email protected].0":
1154-
version "3.6.0"
1155-
resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-3.6.0.tgz#79fc6f652d2362ce0bd3122f6f764a87cc813dea"
1156-
integrity sha512-A+tLuHEMXw+Xz9dmKO7Ho9i4EmMr4tThrwYTlmMNu8y93JxvvRjKFFElpCTS+Z0NlbfuyNdaTlJnAinFbVKm7g==
1153+
"@octokit/[email protected].1":
1154+
version "3.6.1"
1155+
resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-3.6.1.tgz#aa5b02cc211175cbc28ce6c03c73373c1206d632"
1156+
integrity sha512-6oa6CFphIYI7NxxHrdVOzhG7hkcKyGyYocg7lNDSJVauVOLtylg8hNJzoUyPAYKKK0yUeoZamE/lMs2tG+S+JA==
11571157
dependencies:
11581158
"@octokit/auth-oauth-app" "^4.3.0"
11591159
"@octokit/auth-oauth-user" "^1.2.3"
@@ -1289,19 +1289,7 @@
12891289
deprecation "^2.0.0"
12901290
once "^1.4.0"
12911291

1292-
"@octokit/request@^5.3.0", "@octokit/request@^5.4.14":
1293-
version "5.6.0"
1294-
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.0.tgz#6084861b6e4fa21dc40c8e2a739ec5eff597e672"
1295-
integrity sha512-4cPp/N+NqmaGQwbh3vUsYqokQIzt7VjsgTYVXiwpUP2pxd5YiZB2XuTedbb0SPtv9XS7nzAKjAuQxmY8/aZkiA==
1296-
dependencies:
1297-
"@octokit/endpoint" "^6.0.1"
1298-
"@octokit/request-error" "^2.1.0"
1299-
"@octokit/types" "^6.16.1"
1300-
is-plain-object "^5.0.0"
1301-
node-fetch "^2.6.1"
1302-
universal-user-agent "^6.0.0"
1303-
1304-
"@octokit/request@^5.6.0":
1292+
"@octokit/request@^5.3.0", "@octokit/request@^5.4.14", "@octokit/request@^5.6.0":
13051293
version "5.6.1"
13061294
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.1.tgz#f97aff075c37ab1d427c49082fefeef0dba2d8ce"
13071295
integrity sha512-Ls2cfs1OfXaOKzkcxnqw5MR6drMA/zWX/LIS/p8Yjdz7QKTPQLMsB3R+OvoxE6XnXeXEE2X7xe4G4l4X0gRiKQ==

modules/runners/logging.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ locals {
1212
{
1313
"log_group_name" : "user_data",
1414
"prefix_log_group" : true,
15-
"file_path" : var.runner_os == "win" ? "C:/UserData.log" : "/var/log/user-data.log",
15+
"file_path" : var.runner_os == "windows" ? "C:/UserData.log" : "/var/log/user-data.log",
1616
"log_stream_name" : "{instance_id}"
1717
},
1818
{
1919
"log_group_name" : "runner",
2020
"prefix_log_group" : true,
21-
"file_path" : var.runner_os == "win" ? "C:/actions-runner/_diag/Runner_*.log" : "/home/runners/actions-runner/_diag/Runner_**.log",
21+
"file_path" : var.runner_os == "windows" ? "C:/actions-runner/_diag/Runner_*.log" : "/home/runners/actions-runner/_diag/Runner_**.log",
2222
"log_stream_name" : "{instance_id}"
2323
},
2424
{
2525
"log_group_name" : "runner-startup",
2626
"prefix_log_group" : true,
27-
"file_path" : var.runner_os == "win" ? "C:/runner-startup.log" : "/var/log/runner-startup.log",
27+
"file_path" : var.runner_os == "windows" ? "C:/runner-startup.log" : "/var/log/runner-startup.log",
2828
"log_stream_name" : "{instance_id}"
2929
}
3030
]

modules/runners/main.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ locals {
1616
kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : ""
1717

1818
default_ami = {
19-
"win" = { name = ["Windows_Server-20H2-English-Core-ContainersLatest-*"] }
20-
"linux" = var.runner_architecture == "arm64" ? { name = ["amzn2-ami-hvm-2*-arm64-gp2"] } : { name = ["amzn2-ami-hvm-2.*-x86_64-ebs"] }
19+
"windows" = { name = ["Windows_Server-20H2-English-Core-ContainersLatest-*"] }
20+
"linux" = var.runner_architecture == "arm64" ? { name = ["amzn2-ami-hvm-2*-arm64-gp2"] } : { name = ["amzn2-ami-hvm-2.*-x86_64-ebs"] }
2121
}
2222

2323
default_userdata_template = {
24-
"win" = "${path.module}/templates/user-data.ps1"
25-
"linux" = "${path.module}/templates/user-data.sh"
24+
"windows" = "${path.module}/templates/user-data.ps1"
25+
"linux" = "${path.module}/templates/user-data.sh"
2626
}
2727

2828
userdata_install_runner = {
29-
"win" = "${path.module}/templates/install-runner.ps1"
30-
"linux" = "${path.module}/templates/install-runner.sh"
29+
"windows" = "${path.module}/templates/install-runner.ps1"
30+
"linux" = "${path.module}/templates/install-runner.sh"
3131
}
3232

3333
userdata_start_runner = {
34-
"win" = "${path.module}/templates/start-runner.ps1"
35-
"linux" = "${path.module}/templates/start-runner.sh"
34+
"windows" = "${path.module}/templates/start-runner.ps1"
35+
"linux" = "${path.module}/templates/start-runner.sh"
3636
}
3737

3838
ami_filter = coalesce(var.ami_filter, local.default_ami[var.runner_os])

0 commit comments

Comments
 (0)