-
Notifications
You must be signed in to change notification settings - Fork 1
/
gha-runner.pkr.hcl
87 lines (75 loc) · 2.07 KB
/
gha-runner.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
packer {
required_plugins {
amazon = {
version = ">= 0.0.2"
source = "github.com/hashicorp/amazon"
}
}
}
locals {
ami_name = "gha-runner-ubuntu-22.04-LTS-${formatdate("YYYY-MM-DD-hh-mm-ss", timestamp())}"
}
variable "instance_type" {
type = string
default = "t2.medium"
description = "This instance type is 4GB of RAM and 2xCPU"
}
variable "region" {
type = string
default = "eu-west-2"
description = "The region the instance will be launched into"
}
variable "base_ami_image_id" {
type = string
default = "ami-0f540e9f488cfa27d"
description = "The image ID for Amazon's base Ubuntu 22.04LTS image"
}
variable "subnet_id" {
type = string
description = "The ID of the public subnet for the VPC the instance will be launched into"
}
variable "security_group_id" {
type = string
description = "The ID of the security group the instance will be launched into"
}
variable "ssh_username" {
type = string
default = "ubuntu"
description = "The default user for Amazon's Ubuntu image"
}
variable "ssh_private_key_file_path" {
type = string
default = "~/.ssh/gha_runner_image_builder"
description = "Path to the private key for the gha_runner_image_builder keypair"
}
variable "ssh_keypair_name" {
type = string
default = "gha_runner_image_builder"
description = "The name of the EC2 keypair to launch the instance with"
}
source "amazon-ebs" "ubuntu" {
ami_name = local.ami_name
instance_type = var.instance_type
region = var.region
source_ami = var.base_ami_image_id
subnet_id = var.subnet_id
security_group_id = var.security_group_id
ssh_username = var.ssh_username
ssh_private_key_file = var.ssh_private_key_file_path
ssh_keypair_name = var.ssh_keypair_name
ami_block_device_mappings {
device_name = "/dev/sdb"
delete_on_termination = true
volume_type = "gp3"
volume_size = 100
}
}
build {
name = "build-gha-runner"
sources = [
"source.amazon-ebs.ubuntu"
]
provisioner "shell" {
script = "./scripts/init-runner.sh"
}
}