Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions images/linux-al2023/github_agent.linux.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
packer {
required_plugins {
amazon = {
version = ">= 0.0.2"
version = ">= 1.0.0"
source = "github.com/hashicorp/amazon"
}
}
Expand All @@ -12,6 +12,16 @@ variable "runner_version" {
default = null
}

variable "architecture" {
description = "The architecture of the runner. Supported values are 'x64' and 'arm64'"
type = string
default = "x64"
validation {
condition = contains(["arm64", "x64"], var.architecture)
error_message = "`architecture` value is not valid, valid values are: `arm64` and `x64`."
}
}

variable "region" {
description = "The region to build the image in"
type = string
Expand Down Expand Up @@ -39,7 +49,7 @@ variable "associate_public_ip_address" {
variable "instance_type" {
description = "The instance type Packer will use for the builder"
type = string
default = "m3.medium"
default = null
}

variable "iam_instance_profile" {
Expand Down Expand Up @@ -99,11 +109,12 @@ data "http" github_runner_release_json {

locals {
runner_version = coalesce(var.runner_version, trimprefix(jsondecode(data.http.github_runner_release_json.body).tag_name, "v"))
instance_type = coalesce(var.instance_type, var.architecture == "arm64" ? "t4g.medium" : "m3.medium")
}

source "amazon-ebs" "githubrunner" {
ami_name = "github-runner-al2023-x86_64-${formatdate("YYYYMMDDhhmm", timestamp())}"
instance_type = var.instance_type
ami_name = "github-runner-al2023-${var.architecture}-${formatdate("YYYYMMDDhhmm", timestamp())}"
instance_type = local.instance_type
iam_instance_profile = var.iam_instance_profile
region = var.region
security_group_id = var.security_group_id
Expand All @@ -113,7 +124,7 @@ source "amazon-ebs" "githubrunner" {

source_ami_filter {
filters = {
name = "al2023-ami-2023.*-kernel-6.*-x86_64"
name = "al2023-ami-2023.*-kernel-6.*-${var.architecture == "x64" ? "x86_64" : var.architecture}"
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ternary expression could be clearer. Consider extracting the architecture mapping to a local variable for better readability, e.g., locals { ami_architecture = var.architecture == \"x64\" ? \"x86_64\" : var.architecture }.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good recommendation, but not necessary, local.ami_architecture and var.architecture could be confusing, if you decide to implement this suggestion I would use a clearer name for the local variable such as ami_name_architecture to make it clear that is the only place where x86_64 is being used.

root-device-type = "ebs"
virtualization-type = "hvm"
}
Expand Down Expand Up @@ -166,20 +177,19 @@ build {
install_runner = templatefile("../../modules/runners/templates/install-runner.sh", {
ARM_PATCH = ""
S3_LOCATION_RUNNER_DISTRIBUTION = ""
RUNNER_ARCHITECTURE = "x64"
})
})
destination = "/tmp/install-runner.sh"
}

provisioner "shell" {
environment_vars = [
"RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${local.runner_version}/actions-runner-linux-x64-${local.runner_version}.tar.gz"
"RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${local.runner_version}/actions-runner-linux-${var.architecture}-${local.runner_version}.tar.gz"
]
inline = [
"sudo chmod +x /tmp/install-runner.sh",
"echo ec2-user > /tmp/install-user.txt",
"sudo RUNNER_ARCHITECTURE=x64 RUNNER_TARBALL_URL=$RUNNER_TARBALL_URL /tmp/install-runner.sh"
"sudo RUNNER_TARBALL_URL=$RUNNER_TARBALL_URL /tmp/install-runner.sh"
]
}

Expand Down
1 change: 0 additions & 1 deletion modules/runners/templates/install-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## install the runner

s3_location=${S3_LOCATION_RUNNER_DISTRIBUTION}
architecture=${RUNNER_ARCHITECTURE}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason of removing this variable? Is it not used?

Copy link
Contributor

@guicaulada guicaulada Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it's not used, it was introduced in #1624 which added a condition:

if [[ "$architecture" == "arm64" ]]; then
  yum install -y libicu60
fi

But that was eventually removed by #3437 because libcu became needed in all linux architectures:

if [[ ! "$os_id" =~ ^ubuntu.* ]]; then
  dnf install -y libicu
fi


if [ -z "$RUNNER_TARBALL_URL" ] && [ -z "$s3_location" ]; then
echo "Neither RUNNER_TARBALL_URL or s3_location are set"
Expand Down
Loading