diff --git a/main.tf b/main.tf index 759b8169f6..9c72614808 100644 --- a/main.tf +++ b/main.tf @@ -208,6 +208,7 @@ module "runners" { runner_additional_security_group_ids = var.runner_additional_security_group_ids metadata_options = var.runner_metadata_options credit_specification = var.runner_credit_specification + cpu_options = var.runner_cpu_options enable_runner_binaries_syncer = var.enable_runner_binaries_syncer lambda_s3_bucket = var.lambda_s3_bucket diff --git a/modules/multi-runner/runners.tf b/modules/multi-runner/runners.tf index 9f5d1bb456..811ab36260 100644 --- a/modules/multi-runner/runners.tf +++ b/modules/multi-runner/runners.tf @@ -56,6 +56,7 @@ module "runners" { runner_additional_security_group_ids = try(coalescelist(each.value.runner_config.runner_additional_security_group_ids, var.runner_additional_security_group_ids), []) metadata_options = each.value.runner_config.runner_metadata_options credit_specification = each.value.runner_config.credit_specification + cpu_options = each.value.runner_config.cpu_options enable_runner_binaries_syncer = each.value.runner_config.enable_runner_binaries_syncer lambda_s3_bucket = var.lambda_s3_bucket diff --git a/modules/multi-runner/variables.tf b/modules/multi-runner/variables.tf index b138205459..edbdb33059 100644 --- a/modules/multi-runner/variables.tf +++ b/modules/multi-runner/variables.tf @@ -126,6 +126,10 @@ variable "multi_runner_config" { idleCount = number evictionStrategy = optional(string, "oldest_first") })), []) + cpu_options = optional(object({ + core_count = number + threads_per_core = number + }), null) runner_log_files = optional(list(object({ log_group_name = string prefix_log_group = bool diff --git a/modules/runners/main.tf b/modules/runners/main.tf index 4a5e955cc0..e6c3192530 100644 --- a/modules/runners/main.tf +++ b/modules/runners/main.tf @@ -160,6 +160,11 @@ resource "aws_launch_template" "runner" { } } + cpu_options { + core_count = var.cpu_options != null ? var.cpu_options.core_count : null + threads_per_core = var.cpu_options != null ? var.cpu_options.threads_per_core : null + } + monitoring { enabled = var.enable_runner_detailed_monitoring } diff --git a/modules/runners/variables.tf b/modules/runners/variables.tf index f70e80b9cc..a78231e7da 100644 --- a/modules/runners/variables.tf +++ b/modules/runners/variables.tf @@ -662,6 +662,15 @@ variable "credit_specification" { } } +variable "cpu_options" { + description = "The CPU options for the instance. See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template#cpu-options for details. Note that not all instance types support CPU options, see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-optimize-cpu.html#instance-cpu-options" + type = object({ + core_count = number + threads_per_core = number + }) + default = null +} + variable "enable_jit_config" { description = "Overwrite the default behavior for JIT configuration. By default JIT configuration is enabled for ephemeral runners and disabled for non-ephemeral runners. In case of GHES check first if the JIT config API is avaialbe. In case you upgradeing from 3.x to 4.x you can set `enable_jit_config` to `false` to avoid a breaking change when having your own AMI." type = bool diff --git a/variables.tf b/variables.tf index 975aa19b1d..f412d2a486 100644 --- a/variables.tf +++ b/variables.tf @@ -873,6 +873,15 @@ variable "runner_credit_specification" { } } +variable "runner_cpu_options" { + description = "TThe CPU options for the instance. See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template#cpu-options for details. Note that not all instance types support CPU options, see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-optimize-cpu.html#instance-cpu-options" + type = object({ + core_count = number + threads_per_core = number + }) + default = null +} + variable "enable_jit_config" { description = "Overwrite the default behavior for JIT configuration. By default JIT configuration is enabled for ephemeral runners and disabled for non-ephemeral runners. In case of GHES check first if the JIT config API is avaialbe. In case you upgradeing from 3.x to 4.x you can set `enable_jit_config` to `false` to avoid a breaking change when having your own AMI." type = bool