diff --git a/images/linux-amzn2/github_agent.linux.pkr.hcl b/images/linux-amzn2/github_agent.linux.pkr.hcl index e478bd8cef..d039229212 100644 --- a/images/linux-amzn2/github_agent.linux.pkr.hcl +++ b/images/linux-amzn2/github_agent.linux.pkr.hcl @@ -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) @@ -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}" } } @@ -151,4 +158,4 @@ build { ] } -} \ No newline at end of file +} diff --git a/images/ubuntu-focal/github_agent.ubuntu.pkr.hcl b/images/ubuntu-focal/github_agent.ubuntu.pkr.hcl index 02c3d7a21e..9c4f0b44d1 100644 --- a/images/ubuntu-focal/github_agent.ubuntu.pkr.hcl +++ b/images/ubuntu-focal/github_agent.ubuntu.pkr.hcl @@ -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) @@ -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}" } } @@ -161,4 +168,4 @@ build { ] } -} \ No newline at end of file +} diff --git a/images/windows-core-2019/github_agent.windows.pkr.hcl b/images/windows-core-2019/github_agent.windows.pkr.hcl index d15d462476..bde19e3b33 100644 --- a/images/windows-core-2019/github_agent.windows.pkr.hcl +++ b/images/windows-core-2019/github_agent.windows.pkr.hcl @@ -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" @@ -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 { @@ -63,4 +74,4 @@ build { action_runner_url = var.action_runner_url })] } -} \ No newline at end of file +}