Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 6282351

Browse files
HankierGrzegorz Cwiklinski
and
Grzegorz Cwiklinski
authored
feat: Parameterise delete_on_termination (#1758)
Issue: #1745 Variablize delete_on_termination for EBS volume. Make default as true (which make more sense to delete volumes as they are no longer used by runners). Co-authored-by: Grzegorz Cwiklinski <[email protected]@smartpension.co.uk>
1 parent 73953dc commit 6282351

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

Diff for: images/linux-amzn2/github_agent.linux.pkr.hcl

+11-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ variable "root_volume_size_gb" {
4242
default = 8
4343
}
4444

45+
variable "ebs_delete_on_termination" {
46+
description = "Indicates whether the EBS volume is deleted on instance termination."
47+
type = bool
48+
default = true
49+
}
50+
4551
variable "global_tags" {
4652
description = "Tags to apply to everything"
4753
type = map(string)
@@ -91,9 +97,10 @@ source "amazon-ebs" "githubrunner" {
9197

9298

9399
launch_block_device_mappings {
94-
device_name = "/dev/xvda"
95-
volume_size = "${var.root_volume_size_gb}"
96-
volume_type = "gp3"
100+
device_name = "/dev/xvda"
101+
volume_size = "${var.root_volume_size_gb}"
102+
volume_type = "gp3"
103+
delete_on_termination = "${var.ebs_delete_on_termination}"
97104
}
98105
}
99106

@@ -151,4 +158,4 @@ build {
151158
]
152159
}
153160

154-
}
161+
}

Diff for: images/ubuntu-focal/github_agent.ubuntu.pkr.hcl

+11-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ variable "root_volume_size_gb" {
4242
default = 8
4343
}
4444

45+
variable "ebs_delete_on_termination" {
46+
description = "Indicates whether the EBS volume is deleted on instance termination."
47+
type = bool
48+
default = true
49+
}
50+
4551
variable "global_tags" {
4652
description = "Tags to apply to everything"
4753
type = map(string)
@@ -90,9 +96,10 @@ source "amazon-ebs" "githubrunner" {
9096
)
9197

9298
launch_block_device_mappings {
93-
device_name = "/dev/sda1"
94-
volume_size = "${var.root_volume_size_gb}"
95-
volume_type = "gp3"
99+
device_name = "/dev/sda1"
100+
volume_size = "${var.root_volume_size_gb}"
101+
volume_type = "gp3"
102+
delete_on_termination = "${var.ebs_delete_on_termination}"
96103
}
97104
}
98105

@@ -161,4 +168,4 @@ build {
161168
]
162169
}
163170

164-
}
171+
}

Diff for: images/windows-core-2019/github_agent.windows.pkr.hcl

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ variable "region" {
1919
default = "eu-west-1"
2020
}
2121

22+
variable "ebs_delete_on_termination" {
23+
description = "Indicates whether the EBS volume is deleted on instance termination."
24+
type = bool
25+
default = true
26+
}
27+
2228
source "amazon-ebs" "githubrunner" {
2329
ami_name = "github-runner-windows-core-2019-${formatdate("YYYYMMDDhhmm", timestamp())}"
2430
communicator = "winrm"
@@ -43,6 +49,11 @@ source "amazon-ebs" "githubrunner" {
4349
winrm_port = 5986
4450
winrm_use_ssl = true
4551
winrm_username = "Administrator"
52+
53+
launch_block_device_mappings {
54+
device_name = "/dev/sda1"
55+
delete_on_termination = "${var.ebs_delete_on_termination}"
56+
}
4657
}
4758

4859
build {
@@ -63,4 +74,4 @@ build {
6374
action_runner_url = var.action_runner_url
6475
})]
6576
}
66-
}
77+
}

0 commit comments

Comments
 (0)