@@ -18,10 +18,16 @@ variable "region" {
1818 default = " eu-west-1"
1919}
2020
21+ variable "aws_account_number" {
22+ description = " The AWS account number"
23+ type = string
24+ default = " "
25+ }
26+
2127variable "instance_type" {
2228 description = " The instance type Packer will use for the builder"
2329 type = string
24- default = " t3a.medium "
30+ default = " c7i-flex.xlarge "
2531}
2632
2733variable "ebs_delete_on_termination" {
@@ -62,12 +68,21 @@ locals {
6268
6369source "amazon-ebs" "githubrunner" {
6470 ami_name = " github-runner-windows-core-2019-${ formatdate (" YYYYMMDDhhmm" , timestamp ())} "
65- communicator = " winrm"
71+ ami_users = [ var . aws_account_number ]
72+ ami_regions = var. aws_region_mirror_list
73+ ami_description = " GitHub Actions runner AMI Windows Core 2019 Pro Video"
74+
6675 instance_type = var. instance_type
6776 region = var. region
6877 associate_public_ip_address = var. associate_public_ip_address
6978 temporary_security_group_source_public_ip = var. temporary_security_group_source_public_ip
7079
80+ user_data_file = " ../setup-ssh.ps1"
81+ communicator = " ssh"
82+ ssh_username = " Administrator"
83+ ssh_file_transfer_method = " sftp"
84+ ssh_timeout = " 15m"
85+
7186 source_ami_filter {
7287 filters = {
7388 name = " Windows_Server-2019-English-Core-ContainersLatest-*"
@@ -77,19 +92,16 @@ source "amazon-ebs" "githubrunner" {
7792 most_recent = true
7893 owners = [" amazon" ]
7994 }
95+
8096 tags = {
8197 OS_Version = " windows-core-2019"
8298 Release = " Latest"
8399 Base_AMI_Name = " {{ .SourceAMIName }}"
84100 }
85- user_data_file = " ./bootstrap_win.ps1"
86- winrm_insecure = true
87- winrm_port = 5986
88- winrm_use_ssl = true
89- winrm_username = " Administrator"
90101
91102 launch_block_device_mappings {
92103 device_name = " /dev/sda1"
104+ volume_size = 100
93105 delete_on_termination = " ${ var . ebs_delete_on_termination } "
94106 }
95107}
@@ -101,21 +113,29 @@ build {
101113 ]
102114
103115 provisioner "file" {
104- content = templatefile (" ../start-runner.ps1" , {
105- start_runner = templatefile (" ../../modules/runners/ templates/start-runner.ps1" , {})
116+ content = templatefile (" ../../ start-runner.ps1" , {
117+ start_runner = templatefile (" ../../templates/start-runner.ps1" , {})
106118 })
107119 destination = " C:\\ start-runner.ps1"
108120 }
109121
110122 provisioner "powershell" {
111123 inline = concat ([
112- templatefile (" ./windows-provisioner.ps1" , {
124+ templatefile (" ../.. /windows-provisioner.ps1" , {
113125 action_runner_url = " https://github.com/actions/runner/releases/download/v${ local . runner_version } /actions-runner-win-x64-${ local . runner_version } .zip"
114126 })
115127 ], var. custom_shell_commands )
116128 }
129+
130+ # Needed to make the chocolatey install pathing changes stick for any subsequent provisioning script that you want to run.
131+ provisioner "windows-restart" {
132+ restart_check_command = " powershell -command \" & {Write-Output 'Restarted!'}\" "
133+ restart_timeout = " 5m"
134+ }
135+
117136 post-processor "manifest" {
118137 output = " manifest.json"
119138 strip_path = true
120139 }
140+
121141}
0 commit comments