Skip to content

Commit 7ed48b6

Browse files
committed
feat: relax cpu_options schema and add amd_sev_snp + nested_virtualization support
1 parent 6dc97d5 commit 7ed48b6

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

modules/multi-runner/variables.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ variable "multi_runner_config" {
133133
evictionStrategy = optional(string, "oldest_first")
134134
})), [])
135135
cpu_options = optional(object({
136-
core_count = number
137-
threads_per_core = number
136+
core_count = optional(number)
137+
threads_per_core = optional(number)
138+
amd_sev_snp = optional(string)
139+
nested_virtualization = optional(string)
138140
}), null)
139141
placement = optional(object({
140142
affinity = optional(string)

modules/runners/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ resource "aws_launch_template" "runner" {
168168
content {
169169
core_count = try(cpu_options.value.core_count, null)
170170
threads_per_core = try(cpu_options.value.threads_per_core, null)
171+
amd_sev_snp = try(cpu_options.value.amd_sev_snp, null)
172+
nested_virtualization = try(cpu_options.value.nested_virtualization, null)
171173
}
172174
}
173175

modules/runners/variables.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,20 @@ variable "credit_specification" {
637637
variable "cpu_options" {
638638
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"
639639
type = object({
640-
core_count = number
641-
threads_per_core = number
640+
core_count = optional(number)
641+
threads_per_core = optional(number)
642+
amd_sev_snp = optional(string)
643+
nested_virtualization = optional(string)
642644
})
643645
default = null
646+
647+
validation {
648+
condition = var.cpu_options == null ? true : (
649+
(var.cpu_options.amd_sev_snp == null || contains(["enabled", "disabled"], var.cpu_options.amd_sev_snp)) &&
650+
(var.cpu_options.nested_virtualization == null || contains(["enabled", "disabled"], var.cpu_options.nested_virtualization))
651+
)
652+
error_message = "When set, cpu_options.amd_sev_snp and cpu_options.nested_virtualization must be one of: enabled, disabled."
653+
}
644654
}
645655

646656
variable "placement" {

variables.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,10 +868,20 @@ variable "runner_credit_specification" {
868868
variable "runner_cpu_options" {
869869
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"
870870
type = object({
871-
core_count = number
872-
threads_per_core = number
871+
core_count = optional(number)
872+
threads_per_core = optional(number)
873+
amd_sev_snp = optional(string)
874+
nested_virtualization = optional(string)
873875
})
874876
default = null
877+
878+
validation {
879+
condition = var.runner_cpu_options == null ? true : (
880+
(var.runner_cpu_options.amd_sev_snp == null || contains(["enabled", "disabled"], var.runner_cpu_options.amd_sev_snp)) &&
881+
(var.runner_cpu_options.nested_virtualization == null || contains(["enabled", "disabled"], var.runner_cpu_options.nested_virtualization))
882+
)
883+
error_message = "When set, runner_cpu_options.amd_sev_snp and runner_cpu_options.nested_virtualization must be one of: enabled, disabled."
884+
}
875885
}
876886

877887
variable "runner_placement" {

0 commit comments

Comments
 (0)