From 0989a8350831cc342805ca8c206453930b6868cc Mon Sep 17 00:00:00 2001 From: NerdyMcNerd Date: Mon, 29 Sep 2025 12:33:57 +0200 Subject: [PATCH 1/4] fix: allow user data compression to be turned off --- docker_autoscaler.tf | 2 +- variables.tf | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker_autoscaler.tf b/docker_autoscaler.tf index 30a1302c5..9fe972707 100644 --- a/docker_autoscaler.tf +++ b/docker_autoscaler.tf @@ -10,7 +10,7 @@ resource "aws_launch_template" "this" { count = var.runner_worker.type == "docker-autoscaler" ? 1 : 0 name = "${local.name_runner_agent_instance}-worker-launch-template" - user_data = base64gzip(var.runner_worker_docker_autoscaler_instance.start_script) + user_data = var.runner_worker_docker_autoscaler_instance.compress_start_script ? base64gzip(var.runner_worker_docker_autoscaler_instance.start_script) : base64encode(var.runner_worker_docker_autoscaler_instance.start_script) image_id = length(var.runner_worker_docker_autoscaler_ami_id) > 0 ? var.runner_worker_docker_autoscaler_ami_id : data.aws_ami.docker_autoscaler_by_filter[0].id instance_type = length(var.runner_worker_docker_autoscaler_asg.types) > 0 ? var.runner_worker_docker_autoscaler_asg.types[0] : var.runner_worker_docker_autoscaler_asg.default_instance_type key_name = aws_key_pair.autoscaler[0].key_name diff --git a/variables.tf b/variables.tf index 86bf922c8..e04151681 100644 --- a/variables.tf +++ b/variables.tf @@ -769,6 +769,7 @@ variable "runner_worker_docker_autoscaler_instance" { root_device_name = The name of the root volume for the Runner Worker. root_size = The size of the root volume for the Runner Worker. start_script = Cloud-init user data that will be passed to the Runner Worker. Should not be base64 encrypted. + compress_start_script = Gzip-compress the start script to mitigate the ~16 KB user data limit. Not supported on Windows (EC2Launch does not support gzipped user data). Set to false on Windows. volume_type = The type of volume to use for the Runner Worker. `gp2`, `gp3`, `io1` or `io2` are supported. volume_iops = Guaranteed IOPS for the volume. Only supported when using `gp3`, `io1` or `io2` as `volume_type`. volume_throughput = Throughput in MB/s for the volume. Only supported when using `gp3` as `volume_type`. @@ -784,6 +785,7 @@ EOT root_device_name = optional(string, "/dev/sda1") root_size = optional(number, 8) start_script = optional(string, "") + compress_start_script = optional(bool, true) volume_type = optional(string, "gp2") volume_throughput = optional(number, 125) volume_iops = optional(number, 3000) From bfa04ecebc2c801b5863ce8b3c5f1319925c9cd9 Mon Sep 17 00:00:00 2001 From: Matthias Kay Date: Thu, 9 Oct 2025 09:34:58 +0200 Subject: [PATCH 2/4] fix: update start script compression handling for docker-autoscaler The start script compression now supports specifying the algorithm, allowing for gzip or none, improving compatibility with Windows instances. --- docker_autoscaler.tf | 2 +- variables.tf | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docker_autoscaler.tf b/docker_autoscaler.tf index 9fe972707..b7b71577e 100644 --- a/docker_autoscaler.tf +++ b/docker_autoscaler.tf @@ -10,7 +10,7 @@ resource "aws_launch_template" "this" { count = var.runner_worker.type == "docker-autoscaler" ? 1 : 0 name = "${local.name_runner_agent_instance}-worker-launch-template" - user_data = var.runner_worker_docker_autoscaler_instance.compress_start_script ? base64gzip(var.runner_worker_docker_autoscaler_instance.start_script) : base64encode(var.runner_worker_docker_autoscaler_instance.start_script) + user_data = var.runner_worker_docker_autoscaler_instance.start_script_compression_algorithm == "gzip" ? base64gzip(var.runner_worker_docker_autoscaler_instance.start_script) : base64encode(var.runner_worker_docker_autoscaler_instance.start_script) image_id = length(var.runner_worker_docker_autoscaler_ami_id) > 0 ? var.runner_worker_docker_autoscaler_ami_id : data.aws_ami.docker_autoscaler_by_filter[0].id instance_type = length(var.runner_worker_docker_autoscaler_asg.types) > 0 ? var.runner_worker_docker_autoscaler_asg.types[0] : var.runner_worker_docker_autoscaler_asg.default_instance_type key_name = aws_key_pair.autoscaler[0].key_name diff --git a/variables.tf b/variables.tf index e04151681..fc4044e2f 100644 --- a/variables.tf +++ b/variables.tf @@ -769,7 +769,7 @@ variable "runner_worker_docker_autoscaler_instance" { root_device_name = The name of the root volume for the Runner Worker. root_size = The size of the root volume for the Runner Worker. start_script = Cloud-init user data that will be passed to the Runner Worker. Should not be base64 encrypted. - compress_start_script = Gzip-compress the start script to mitigate the ~16 KB user data limit. Not supported on Windows (EC2Launch does not support gzipped user data). Set to false on Windows. + start_script_compression_algorithm = `gzip` compress the start script to mitigate the ~16 KB user data limit. Use `none` for Windows (EC2Launch does not support gzipped user data). volume_type = The type of volume to use for the Runner Worker. `gp2`, `gp3`, `io1` or `io2` are supported. volume_iops = Guaranteed IOPS for the volume. Only supported when using `gp3`, `io1` or `io2` as `volume_type`. volume_throughput = Throughput in MB/s for the volume. Only supported when using `gp3` as `volume_type`. @@ -785,12 +785,17 @@ EOT root_device_name = optional(string, "/dev/sda1") root_size = optional(number, 8) start_script = optional(string, "") - compress_start_script = optional(bool, true) + start_script_compression_algorithm = optional(string, "gzip") volume_type = optional(string, "gp2") volume_throughput = optional(number, 125) volume_iops = optional(number, 3000) }) default = {} + + validation { + condition = contains(["gzip", "nono"], var.runner_worker_docker_autoscaler_instance.start_script_compression_algorithm) + error_message = "The start_script_compression_algorithm supports `gzip` or `none`" + } } variable "runner_worker_docker_autoscaler_asg" { From a7236205d6215c159124dc9f7747613169cd1ea3 Mon Sep 17 00:00:00 2001 From: Matthias Kay Date: Thu, 9 Oct 2025 09:40:28 +0200 Subject: [PATCH 3/4] fix: correct formatting and validation structure in variables.tf --- variables.tf | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/variables.tf b/variables.tf index fc4044e2f..6e2743cef 100644 --- a/variables.tf +++ b/variables.tf @@ -778,24 +778,24 @@ EOT type = object({ ebs_optimized = optional(bool, true) # TODO should always be "required", right? https://aquasecurity.github.io/tfsec/v1.28.0/checks/aws/ec2/enforce-launch-config-http-token-imds/ - http_tokens = optional(string, "required") - http_put_response_hop_limit = optional(number, 2) - monitoring = optional(bool, false) - private_address_only = optional(bool, true) - root_device_name = optional(string, "/dev/sda1") - root_size = optional(number, 8) - start_script = optional(string, "") - start_script_compression_algorithm = optional(string, "gzip") - volume_type = optional(string, "gp2") - volume_throughput = optional(number, 125) - volume_iops = optional(number, 3000) + http_tokens = optional(string, "required") + http_put_response_hop_limit = optional(number, 2) + monitoring = optional(bool, false) + private_address_only = optional(bool, true) + root_device_name = optional(string, "/dev/sda1") + root_size = optional(number, 8) + start_script = optional(string, "") + start_script_compression_algorithm = optional(string, "gzip") + volume_type = optional(string, "gp2") + volume_throughput = optional(number, 125) + volume_iops = optional(number, 3000) }) default = {} - validation { - condition = contains(["gzip", "nono"], var.runner_worker_docker_autoscaler_instance.start_script_compression_algorithm) - error_message = "The start_script_compression_algorithm supports `gzip` or `none`" - } + validation { + condition = contains(["gzip", "nono"], var.runner_worker_docker_autoscaler_instance.start_script_compression_algorithm) + error_message = "The start_script_compression_algorithm supports `gzip` or `none`" + } } variable "runner_worker_docker_autoscaler_asg" { From d7e5a5013183dd55267b19e39b87c04ecdd90df9 Mon Sep 17 00:00:00 2001 From: Matthias Kay Date: Thu, 9 Oct 2025 09:43:02 +0200 Subject: [PATCH 4/4] fix: update validation for start_script_compression_algorithm to include 'none' --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 6e2743cef..d3e9dd077 100644 --- a/variables.tf +++ b/variables.tf @@ -793,7 +793,7 @@ EOT default = {} validation { - condition = contains(["gzip", "nono"], var.runner_worker_docker_autoscaler_instance.start_script_compression_algorithm) + condition = contains(["gzip", "none"], var.runner_worker_docker_autoscaler_instance.start_script_compression_algorithm) error_message = "The start_script_compression_algorithm supports `gzip` or `none`" } }