Skip to content

Commit 139cb9c

Browse files
committed
Make ARM/ICU patch conditional in user_data.sh.
1 parent 358e768 commit 139cb9c

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ locals {
44
})
55

66
s3_action_runner_url = "s3://${module.runner_binaries.bucket.id}/${module.runner_binaries.runner_distribution_object_key}"
7+
runner_architecture = substr(var.instance_type, 0, 2) == "a1" || substr(var.instance_type, 1, 2) == "6g" ? "arm64" : "x64"
78
}
89

910
resource "random_string" "random" {
@@ -62,7 +63,8 @@ module "runners" {
6263

6364
instance_type = var.instance_type
6465

65-
ami_filter = substr(var.instance_type, 0, 2) == "a1" || substr(var.instance_type, 1, 2) == "6g" ? { name = ["amzn2-ami-hvm-2*-arm64-gp2"] } : { name = ["amzn2-ami-hvm-2.*-x86_64-ebs"] }
66+
runner_architecture = local.runner_architecture
67+
ami_filter = local.runner_architecture == "arm64" ? { name = ["amzn2-ami-hvm-2*-arm64-gp2"] } : { name = ["amzn2-ami-hvm-2.*-x86_64-ebs"] }
6668

6769
sqs_build_queue = aws_sqs_queue.queued_builds
6870
github_app = var.github_app

modules/runners/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ resource "aws_launch_template" "runner" {
7979
post_install = var.userdata_post_install
8080
s3_location_runner_distribution = var.s3_location_runner_binaries
8181
service_user = var.runner_as_root ? "root" : "ec2-user"
82+
runner_architecture = var.runner_architecture
8283
}))
8384

8485
tags = local.tags

modules/runners/templates/user-data.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ aws s3 cp ${s3_location_runner_distribution} actions-runner.tar.gz
2020
tar xzf ./actions-runner.tar.gz
2121
rm -rf actions-runner.tar.gz
2222

23+
%{ if runner_architecture == "arm64" ~}
2324
# Patch for ARM64 (no ICU install by default)
2425
yum install -y patch
2526
patch -p1 <<ICU_PATCH
@@ -69,6 +70,7 @@ diff -Naur a/bin/Runner.Worker.runtimeconfig.json b/bin/Runner.Worker.runtimecon
6970
\ No newline at end of file
7071
+}
7172
ICU_PATCH
73+
%{ endif ~}
7274

7375
INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
7476
REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region)

modules/runners/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,9 @@ variable "encryption" {
184184
encrypt = bool
185185
})
186186
}
187+
188+
variable "runner_architecture" {
189+
description = "The platform architecture of the runner instance_type."
190+
type = string
191+
default = "x64"
192+
}

0 commit comments

Comments
 (0)