Skip to content

Commit 796856a

Browse files
authored
feat: support setting throughput and iops for ebs volumes (#1063)
## Description These changes will add support for setting `throughput` and `iops` to the EBS device that is being attached to the docker_machine instance. Because setting `iops` is now possible, this will also allow the usage of `io1` and `io2` EBS volumes types. ## Migrations required No - If you consider my defaults for the two new variables as sane. ## Verification I have adapted the module configuration by changing the `runner_worker_docker_machine_instance` input variables: ``` runner_worker_docker_machine_instance = { private_address_only = false types = ["m5.large", "t3.xlarge", "m6a.large"] subnet_ids = [module.vpc.public_subnets[0]] runners_idle_time = 180 root_size = 30 volume_type = "io2" volume_iops = 6000 } ``` The volume was created successfully when testing the runner via Gitlab: <img width="1144" alt="Screenshot 2024-01-06 at 12 14 09" src="https://github.com/cattle-ops/terraform-aws-gitlab-runner/assets/25439373/0beca11e-78fd-4ac7-ae9d-47df3c5c1a9f">
1 parent 74558b8 commit 796856a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ resource "aws_launch_template" "fleet_gitlab_runner" {
330330
ebs {
331331
volume_size = var.runner_worker_docker_machine_instance.root_size
332332
volume_type = var.runner_worker_docker_machine_instance.volume_type
333+
iops = contains(["gp3", "io1", "io2"], var.runner_worker_docker_machine_instance.volume_type) ? var.runner_worker_docker_machine_instance.volume_iops : null
334+
throughput = var.runner_worker_docker_machine_instance.volume_type == "gp3" ? var.runner_worker_docker_machine_instance.volume_throughput : null
333335
}
334336
}
335337

variables.tf

+10-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ variable "runner_worker_docker_machine_instance" {
666666
start_script = Cloud-init user data that will be passed to the Runner Worker. Should not be base64 encrypted.
667667
subnet_ids = The list of subnet IDs to use for the Runner Worker when the fleet mode is enabled.
668668
types = The type of instance to use for the Runner Worker. In case of fleet mode, multiple instance types are supported.
669-
volume_type = The type of volume to use for the Runner Worker.
669+
volume_type = The type of volume to use for the Runner Worker. `gp2`, `gp3`, `io1` or `io2` are supported.
670+
volume_throughput = Throughput in MB/s for the volume. Only supported when using `gp3` as `volume_type`.
671+
volume_iops = Guaranteed IOPS for the volume. Only supported when using `gp3`, `io1` or `io2` as `volume_type`.
670672
EOT
671673
type = object({
672674
destroy_after_max_builds = optional(number, 0)
@@ -683,6 +685,8 @@ variable "runner_worker_docker_machine_instance" {
683685
subnet_ids = optional(list(string), [])
684686
types = optional(list(string), ["m5.large"])
685687
volume_type = optional(string, "gp2")
688+
volume_throughput = optional(number, 125)
689+
volume_iops = optional(number, 3000)
686690
})
687691
default = {
688692
}
@@ -696,6 +700,11 @@ variable "runner_worker_docker_machine_instance" {
696700
condition = var.runner_worker_docker_machine_instance.name_prefix == "" || can(regex("^[a-zA-Z0-9\\.-]+$", var.runner_worker_docker_machine_instance.name_prefix))
697701
error_message = "Valid characters for the docker+machine executor name are: [a-zA-Z0-9\\.-]."
698702
}
703+
704+
validation {
705+
condition = contains(["gp2", "gp3", "io1", "io2"], var.runner_worker_docker_machine_instance.volume_type)
706+
error_message = "Supported volume types: gp2, gp3, io1 and io2"
707+
}
699708
}
700709

701710
variable "runner_worker_docker_machine_instance_spot" {

0 commit comments

Comments
 (0)