Skip to content

Commit

Permalink
feat: Parameterise delete_on_termination (philips-labs#1758)
Browse files Browse the repository at this point in the history
Issue: philips-labs#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 <grzegorz.cwiklinski@grzegorz.cwiklinski@smartpension.co.uk>
  • Loading branch information
Hankier and Grzegorz Cwiklinski authored Feb 16, 2022
1 parent 73953dc commit 6282351
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
15 changes: 11 additions & 4 deletions images/linux-amzn2/github_agent.linux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "root_volume_size_gb" {
default = 8
}

variable "ebs_delete_on_termination" {
description = "Indicates whether the EBS volume is deleted on instance termination."
type = bool
default = true
}

variable "global_tags" {
description = "Tags to apply to everything"
type = map(string)
Expand Down Expand Up @@ -91,9 +97,10 @@ source "amazon-ebs" "githubrunner" {


launch_block_device_mappings {
device_name = "/dev/xvda"
volume_size = "${var.root_volume_size_gb}"
volume_type = "gp3"
device_name = "/dev/xvda"
volume_size = "${var.root_volume_size_gb}"
volume_type = "gp3"
delete_on_termination = "${var.ebs_delete_on_termination}"
}
}

Expand Down Expand Up @@ -151,4 +158,4 @@ build {
]
}

}
}
15 changes: 11 additions & 4 deletions images/ubuntu-focal/github_agent.ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "root_volume_size_gb" {
default = 8
}

variable "ebs_delete_on_termination" {
description = "Indicates whether the EBS volume is deleted on instance termination."
type = bool
default = true
}

variable "global_tags" {
description = "Tags to apply to everything"
type = map(string)
Expand Down Expand Up @@ -90,9 +96,10 @@ source "amazon-ebs" "githubrunner" {
)

launch_block_device_mappings {
device_name = "/dev/sda1"
volume_size = "${var.root_volume_size_gb}"
volume_type = "gp3"
device_name = "/dev/sda1"
volume_size = "${var.root_volume_size_gb}"
volume_type = "gp3"
delete_on_termination = "${var.ebs_delete_on_termination}"
}
}

Expand Down Expand Up @@ -161,4 +168,4 @@ build {
]
}

}
}
13 changes: 12 additions & 1 deletion images/windows-core-2019/github_agent.windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ variable "region" {
default = "eu-west-1"
}

variable "ebs_delete_on_termination" {
description = "Indicates whether the EBS volume is deleted on instance termination."
type = bool
default = true
}

source "amazon-ebs" "githubrunner" {
ami_name = "github-runner-windows-core-2019-${formatdate("YYYYMMDDhhmm", timestamp())}"
communicator = "winrm"
Expand All @@ -43,6 +49,11 @@ source "amazon-ebs" "githubrunner" {
winrm_port = 5986
winrm_use_ssl = true
winrm_username = "Administrator"

launch_block_device_mappings {
device_name = "/dev/sda1"
delete_on_termination = "${var.ebs_delete_on_termination}"
}
}

build {
Expand All @@ -63,4 +74,4 @@ build {
action_runner_url = var.action_runner_url
})]
}
}
}

0 comments on commit 6282351

Please sign in to comment.