Skip to content

Commit

Permalink
feat: Variablize delete_on_termination
Browse files Browse the repository at this point in the history
    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).
  • Loading branch information
Grzegorz Cwiklinski committed Feb 15, 2022
1 parent 0cf2b5d commit cbc26fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 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 {
]
}

}
}

0 comments on commit cbc26fc

Please sign in to comment.