1
1
packer {
2
2
required_plugins {
3
3
amazon = {
4
- version = " >= 0 .0.2 "
4
+ version = " >= 1 .0.0 "
5
5
source = " github.com/hashicorp/amazon"
6
6
}
7
7
}
@@ -12,6 +12,16 @@ variable "runner_version" {
12
12
default = null
13
13
}
14
14
15
+ variable "architecture" {
16
+ description = " The architecture of the runner. Supported values are 'x86-64' and 'arm64'"
17
+ type = string
18
+ default = " x86_64"
19
+ validation {
20
+ condition = contains ([" arm64" , " x86_64" ], var. architecture )
21
+ error_message = " `lambda_architecture` value is not valid, valid values are: `arm64` and `x86_64`."
22
+ }
23
+ }
24
+
15
25
variable "region" {
16
26
description = " The region to build the image in"
17
27
type = string
@@ -39,7 +49,7 @@ variable "associate_public_ip_address" {
39
49
variable "instance_type" {
40
50
description = " The instance type Packer will use for the builder"
41
51
type = string
42
- default = " m3.medium "
52
+ default = " t4g.small "
43
53
}
44
54
45
55
variable "iam_instance_profile" {
@@ -99,12 +109,13 @@ data "http" github_runner_release_json {
99
109
100
110
locals {
101
111
runner_version = coalesce (var. runner_version , trimprefix (jsondecode (data. http . github_runner_release_json . body ). tag_name , " v" ))
112
+ instance_type = coalesce (var. instance_type , var. architecture == " arm64" ? " t4g.small" : " m3.medium" )
102
113
}
103
114
104
115
source "amazon-ebs" "githubrunner" {
105
- ami_name = " github-runner-al2023-x86_64 -${ formatdate (" YYYYMMDDhhmm" , timestamp ())} "
116
+ ami_name = " github-runner-al2023-${ var . architecture } -${ formatdate (" YYYYMMDDhhmm" , timestamp ())} "
106
117
instance_type = var. instance_type
107
- iam_instance_profile = var. iam_instance_profile
118
+ iam_instance_profile = var. iam_instance_profile
108
119
region = var. region
109
120
security_group_id = var. security_group_id
110
121
subnet_id = var. subnet_id
@@ -113,7 +124,7 @@ source "amazon-ebs" "githubrunner" {
113
124
114
125
source_ami_filter {
115
126
filters = {
116
- name = " al2023-ami-2023.*-kernel-6.*-x86_64 "
127
+ name = " al2023-ami-2023.*-kernel-6.*-${ var . architecture } "
117
128
root-device-type = " ebs"
118
129
virtualization-type = " hvm"
119
130
}
@@ -166,20 +177,19 @@ build {
166
177
install_runner = templatefile (" ../../modules/runners/templates/install-runner.sh" , {
167
178
ARM_PATCH = " "
168
179
S3_LOCATION_RUNNER_DISTRIBUTION = " "
169
- RUNNER_ARCHITECTURE = " x64"
170
180
})
171
181
})
172
182
destination = " /tmp/install-runner.sh"
173
183
}
174
184
175
185
provisioner "shell" {
176
186
environment_vars = [
177
- " RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${ local . runner_version } /actions-runner-linux-x64 -${ local . runner_version } .tar.gz"
187
+ " RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${ local . runner_version } /actions-runner-linux-${ var . architecture } -${ local . runner_version } .tar.gz"
178
188
]
179
189
inline = [
180
190
" sudo chmod +x /tmp/install-runner.sh" ,
181
191
" echo ec2-user > /tmp/install-user.txt" ,
182
- " sudo RUNNER_ARCHITECTURE=x64 RUNNER_TARBALL_URL=$RUNNER_TARBALL_URL /tmp/install-runner.sh"
192
+ " sudo RUNNER_TARBALL_URL=$RUNNER_TARBALL_URL /tmp/install-runner.sh"
183
193
]
184
194
}
185
195
0 commit comments