@@ -7,10 +7,10 @@ packer {
77 }
88}
99
10- variable "action_runner_url " {
11- description = " The URL to the tarball of the action runner"
10+ variable "runner_version " {
11+ description = " The version (no v prefix) of the runner software to install https://github.com/actions/ runner/releases "
1212 type = string
13- default = " https://github.com/actions/runner/releases/download/v2.284.0/actions-runner-linux-x64-2.284.0.tar.gz "
13+ default = " 2.286.0 "
1414}
1515
1616variable "region" {
@@ -19,10 +19,41 @@ variable "region" {
1919 default = " eu-west-1"
2020}
2121
22+ variable "security_group_id" {
23+ description = " The ID of the security group Packer will associate with the builder to enable access"
24+ type = string
25+ default = null
26+ }
27+
28+ variable "subnet_id" {
29+ description = " If using VPC, the ID of the subnet, such as subnet-12345def, where Packer will launch the EC2 instance. This field is required if you are using an non-default VPC"
30+ type = string
31+ default = null
32+ }
33+
34+ variable "instance_type" {
35+ description = " The instance type Packer will use for the builder"
36+ type = string
37+ default = " m3.medium"
38+ }
39+
40+ variable "root_volume_size_gb" {
41+ type = number
42+ default = 8
43+ }
44+
45+ variable "tags" {
46+ description = " Additional tags to add globally"
47+ type = map (string )
48+ default = {}
49+ }
50+
2251source "amazon-ebs" "githubrunner" {
23- ami_name = " github-runner-amzn2-x86_64-${ formatdate (" YYYYMMDDhhmm" , timestamp ())} "
24- instance_type = " m3.medium"
25- region = var. region
52+ ami_name = " github-runner-amzn2-x86_64-${ formatdate (" YYYYMMDDhhmm" , timestamp ())} "
53+ instance_type = var. instance_type
54+ region = var. region
55+ security_group_id = var. security_group_id
56+ subnet_id = var. subnet_id
2657 source_ami_filter {
2758 filters = {
2859 name = " amzn2-ami-hvm-2.*-x86_64-ebs"
@@ -33,10 +64,18 @@ source "amazon-ebs" "githubrunner" {
3364 owners = [" 137112412989" ]
3465 }
3566 ssh_username = " ec2-user"
36- tags = {
37- OS_Version = " amzn2"
38- Release = " Latest"
39- Base_AMI_Name = " {{ .SourceAMIName }}"
67+ tags = merge (
68+ var. tags ,
69+ {
70+ OS_Version = " amzn2"
71+ Release = " Latest"
72+ Base_AMI_Name = " {{ .SourceAMIName }}"
73+ })
74+
75+ launch_block_device_mappings {
76+ device_name = " /dev/xvda"
77+ volume_size = " ${ var . root_volume_size_gb } "
78+ volume_type = " gp3"
4079 }
4180}
4281
@@ -58,16 +97,24 @@ build {
5897 ]
5998 }
6099
61- provisioner "shell" {
62- environment_vars = [
63- " RUNNER_TARBALL_URL=${ var . action_runner_url } "
64- ]
65- inline = [templatefile (" ../install-runner.sh" , {
100+ provisioner "file" {
101+ content = templatefile (" ../install-runner.sh" , {
66102 install_runner = templatefile (" ../../modules/runners/templates/install-runner.sh" , {
67103 ARM_PATCH = " "
68104 S3_LOCATION_RUNNER_DISTRIBUTION = " "
69105 })
70- })]
106+ })
107+ destination = " /tmp/install-runner.sh"
108+ }
109+
110+ provisioner "shell" {
111+ environment_vars = [
112+ " RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${ var . runner_version } /actions-runner-linux-x64-${ var . runner_version } .tar.gz"
113+ ]
114+ inline = [
115+ " sudo chmod +x /tmp/install-runner.sh" ,
116+ " sudo RUNNER_TARBALL_URL=$RUNNER_TARBALL_URL /tmp/install-runner.sh"
117+ ]
71118 }
72119
73120 provisioner "file" {
0 commit comments