Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 74cfa51

Browse files
authored
feat(runner): Replace patch by install ICU package for ARM runners (#1624)
* Update arm-runner-patch.tpl The runtimeconfig.json files seem to have changed on the latest Amazon Linux AMI. When running the user data scripts, the patch of these files fails which causes initialization of the runner instance to fail. * fix patch again * install libicu60 instead of patching * remove arm-patch * Revert "remove arm-patch" This reverts commit 639c46e15b37935264842a360d55a1d1d8ad0051. * Add ARM64 documentation * Remove arm-runner-patch.tpl and include in install-runner.sh * add arm64, ephemeral and windows examples to github workflow
1 parent a6e6efd commit 74cfa51

File tree

15 files changed

+248
-62
lines changed

15 files changed

+248
-62
lines changed

Diff for: .github/workflows/terraform.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
fail-fast: false
4444
matrix:
4545
terraform: [0.14.3, 0.15.5, 1.0.8]
46-
example: ["default", "ubuntu", "prebuilt"]
46+
example: ["default", "ubuntu", "prebuilt", "arm64", "ephemeral", "windows"]
4747
defaults:
4848
run:
4949
working-directory: examples/${{ matrix.example }}

Diff for: README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ To be able to support a number of use-cases the module has quite a lot configura
9393

9494
#### ARM64 support via Graviton/Graviton2 instance-types
9595

96-
When using the default example or top-level module, specifying an `instance_type` that matches a Graviton/Graviton 2 (ARM64) architecture (e.g. a1, t4g or any 6th-gen `g` or `gd` type), the sub-modules will be automatically configured to provision with ARM64 AMIs and leverage GitHub's ARM64 action runner. See below for more details.
96+
When using the default example or top-level module, specifying `instance_types` that match a Graviton/Graviton 2 (ARM64) architecture (e.g. a1, t4g or any 6th-gen `g` or `gd` type), you must also specify `runner_architecture = "arm64"` and the sub-modules will be automatically configured to provision with ARM64 AMIs and leverage GitHub's ARM64 action runner. See below for more details.
9797

9898
## Usages
9999

@@ -184,8 +184,6 @@ module "github-runner" {
184184
}
185185
```
186186

187-
**ARM64** support: Specify an `a1`, `t4g` or `*6g*` (6th-gen Graviton2) instance type to stand up an ARM64 runner, otherwise the default is x86_64.
188-
189187
Run terraform by using the following commands
190188

191189
```bash
@@ -322,9 +320,10 @@ This module also allows you to run agents from a prebuilt AMI to gain faster sta
322320
Examples are located in the [examples](./examples) directory. The following examples are provided:
323321

324322
- _[Default](examples/default/README.md)_: The default example of the module
323+
- _[ARM64](examples/arm64/README.md)_: Example usage with ARM64 architecture
325324
- _[Ubuntu](examples/ubuntu/README.md)_: Example usage of creating a runner using Ubuntu AMIs.
326325
- _[Windows](examples/windows/README.md)_: Example usage of creating a runner using Windows as the OS.
327-
- _[Ephemeral](examples/ephemeral/README.md) : Example usages of ephemeral runners based on the default example.
326+
- _[Ephemeral](examples/ephemeral/README.md)_: Example usages of ephemeral runners based on the default example.
328327
- _[Prebuilt Images](examples/prebuilt/README.md)_: Example usages of deploying runners with a custom prebuilt image.
329328
- _[Permissions boundary](examples/permissions-boundary/README.md)_: Example usages of permissions boundaries.
330329

@@ -345,7 +344,7 @@ The following sub modules are optional and are provided as example or utility:
345344

346345
### ARM64 configuration for submodules
347346

348-
When using the top level module configure `runner_architecture = arm64` and insure the list of `instance_types` matches. When not using the top-level ensure the bot properties are set on the submodules.
347+
When using the top level module configure `runner_architecture = "arm64"` and ensure the list of `instance_types` matches. When not using the top-level, ensure these properties are set on the submodules.
349348

350349
## Debugging
351350

@@ -354,7 +353,7 @@ In case the setup does not work as intended follow the trace of events:
354353
- In the GitHub App configuration, the Advanced page displays all webhook events that were sent.
355354
- In AWS CloudWatch, every lambda has a log group. Look at the logs of the `webhook` and `scale-up` lambdas.
356355
- In AWS SQS you can see messages available or in flight.
357-
- Once an EC2 instance is running, you can connect to it in the EC2 user interface using Session Manager. Check the user data script using `cat /var/log/user-data.log`. By default several log files of the instances are streamed to AWS CloudWatch, look for a log group named `<environment>/runners`. In the log group you should see at least the log streams for the user data installation and runner agent.
356+
- Once an EC2 instance is running, you can connect to it in the EC2 user interface using Session Manager (use `enable_ssm_on_runners = true`). Check the user data script using `cat /var/log/user-data.log`. By default several log files of the instances are streamed to AWS CloudWatch, look for a log group named `<environment>/runners`. In the log group you should see at least the log streams for the user data installation and runner agent.
358357
- Registered instances should show up in the Settings - Actions page of the repository or organization (depending on the installation mode).
359358

360359
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Diff for: examples/arm64/.terraform.lock.hcl

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: examples/arm64/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Action runners deployment with ARM64 architecture
2+
3+
This module shows how to create GitHub action runners using AWS Graviton instances which have ARM64 architecture. Lambda release will be downloaded from GitHub.
4+
5+
## Usages
6+
7+
Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simply remove the location of the lambda zip files, the default location will work in this case.
8+
9+
> Ensure you have set the version in `lambdas-download/main.tf` for running the example. The version needs to be set to a GitHub release version, see https://github.com/philips-labs/terraform-aws-github-runner/releases
10+
11+
```bash
12+
cd lambdas-download
13+
terraform init
14+
terraform apply
15+
cd ..
16+
```
17+
18+
Before running Terraform, ensure the GitHub app is configured. See the [configuration details](../../README.md#usages) for more details.
19+
20+
```bash
21+
terraform init
22+
terraform apply
23+
```
24+
25+
You can receive the webhook details by running:
26+
27+
```bash
28+
terraform output -raw webhook_secret
29+
```
30+
31+
Be-aware some shells will print some end of line character `%`.

Diff for: examples/arm64/lambdas-download/main.tf

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
locals {
2+
version = "<REPLACE_BY_GITHUB_RELEASE_VERSION>"
3+
}
4+
5+
module "lambdas" {
6+
source = "../../../modules/download-lambda"
7+
lambdas = [
8+
{
9+
name = "webhook"
10+
tag = local.version
11+
},
12+
{
13+
name = "runners"
14+
tag = local.version
15+
},
16+
{
17+
name = "runner-binaries-syncer"
18+
tag = local.version
19+
}
20+
]
21+
}
22+
23+
output "files" {
24+
value = module.lambdas.files
25+
}

Diff for: examples/arm64/main.tf

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
locals {
2+
environment = "default"
3+
aws_region = "eu-west-1"
4+
}
5+
6+
resource "random_id" "random" {
7+
byte_length = 20
8+
}
9+
10+
11+
################################################################################
12+
### Hybrid account
13+
################################################################################
14+
15+
module "runners" {
16+
source = "../../"
17+
create_service_linked_role_spot = true
18+
aws_region = local.aws_region
19+
vpc_id = module.vpc.vpc_id
20+
subnet_ids = module.vpc.private_subnets
21+
22+
environment = local.environment
23+
tags = {
24+
Project = "ProjectX"
25+
}
26+
27+
github_app = {
28+
key_base64 = var.github_app_key_base64
29+
id = var.github_app_id
30+
webhook_secret = random_id.random.hex
31+
}
32+
33+
# Grab zip files via lambda_download, will automatically get the ARM64 build
34+
webhook_lambda_zip = "lambdas-download/webhook.zip"
35+
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
36+
runners_lambda_zip = "lambdas-download/runners.zip"
37+
38+
enable_organization_runners = false
39+
# Runners will automatically get the "arm64" label
40+
runner_extra_labels = "default,example"
41+
42+
# enable access to the runners via SSM
43+
enable_ssm_on_runners = true
44+
45+
# use S3 or KMS SSE to runners S3 bucket
46+
# runner_binaries_s3_sse_configuration = {
47+
# rule = {
48+
# apply_server_side_encryption_by_default = {
49+
# sse_algorithm = "AES256"
50+
# }
51+
# }
52+
# }
53+
54+
# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
55+
# idle_config = [{
56+
# cron = "* * 9-17 * * *"
57+
# timeZone = "Europe/Amsterdam"
58+
# idleCount = 1
59+
# }]
60+
61+
# Let the module manage the service linked role
62+
# create_service_linked_role_spot = true
63+
64+
runner_architecture = "arm64"
65+
# Ensure all instance types have ARM64 architecture (ie. AWS Graviton processors)
66+
instance_types = ["t4g.large", "c6g.large"]
67+
68+
# override delay of events in seconds
69+
delay_webhook_event = 5
70+
runners_maximum_count = 1
71+
72+
# set up a fifo queue to remain order
73+
fifo_build_queue = true
74+
75+
# override scaling down
76+
scale_down_schedule_expression = "cron(* * * * ? *)"
77+
}

Diff for: examples/arm64/outputs.tf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
output "runners" {
2+
value = {
3+
lambda_syncer_name = module.runners.binaries_syncer.lambda.function_name
4+
}
5+
}
6+
7+
output "webhook_endpoint" {
8+
value = module.runners.webhook.endpoint
9+
}
10+
11+
output "webhook_secret" {
12+
sensitive = true
13+
value = random_id.random.hex
14+
}
15+

Diff for: examples/arm64/providers.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = local.aws_region
3+
}

Diff for: examples/arm64/variables.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
variable "github_app_key_base64" {}
3+
4+
variable "github_app_id" {}

Diff for: examples/arm64/versions.tf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = ">= 3.27"
6+
}
7+
local = {
8+
source = "hashicorp/local"
9+
}
10+
random = {
11+
source = "hashicorp/random"
12+
}
13+
}
14+
required_version = ">= 0.14"
15+
}

Diff for: examples/arm64/vpc.tf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module "vpc" {
2+
source = "git::https://github.com/philips-software/terraform-aws-vpc.git?ref=2.2.0"
3+
4+
environment = local.environment
5+
aws_region = local.aws_region
6+
create_private_hosted_zone = false
7+
}

Diff for: examples/default/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resource "random_id" "random" {
99

1010

1111
################################################################################
12-
### Hybrid acccount
12+
### Hybrid account
1313
################################################################################
1414

1515
module "runners" {

Diff for: modules/runners/main.tf

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ locals {
1212
instance_profile_path = var.instance_profile_path == null ? "/${var.environment}/" : var.instance_profile_path
1313
lambda_zip = var.lambda_zip == null ? "${path.module}/lambdas/runners/runners.zip" : var.lambda_zip
1414
userdata_template = var.userdata_template == null ? local.default_userdata_template[var.runner_os] : var.userdata_template
15-
userdata_arm_patch = "${path.module}/templates/arm-runner-patch.tpl"
1615
kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : ""
1716

1817
default_ami = {
@@ -119,7 +118,7 @@ resource "aws_launch_template" "runner" {
119118
pre_install = var.userdata_pre_install
120119
install_runner = templatefile(local.userdata_install_runner[var.runner_os], {
121120
S3_LOCATION_RUNNER_DISTRIBUTION = var.s3_location_runner_binaries
122-
ARM_PATCH = var.runner_architecture == "arm64" ? templatefile(local.userdata_arm_patch, {}) : ""
121+
RUNNER_ARCHITECTURE = var.runner_architecture
123122
})
124123
post_install = var.userdata_post_install
125124
start_runner = templatefile(local.userdata_start_runner[var.runner_os], {})

Diff for: modules/runners/templates/arm-runner-patch.tpl

-49
This file was deleted.

0 commit comments

Comments
 (0)