Add support for advanced machine features to compute-vm (#2855)

* add support for advanced machine features to compute-vm

* fix validation

* Update modules/compute-vm/variables.tf

Co-authored-by: Wiktor Niesiobędzki <wiktorn@google.com>

---------

Co-authored-by: Wiktor Niesiobędzki <wiktorn@google.com>
This commit is contained in:
Ludovico Magnocavallo
2025-01-31 10:27:29 +01:00
committed by GitHub
parent efa1ef6f7e
commit a002ead06b
3 changed files with 90 additions and 12 deletions

View File

@@ -292,6 +292,14 @@ variable "network_interfaces" {
variable "options" {
description = "Instance options."
type = object({
advanced_machine_features = optional(object({
enable_nested_virtualization = optional(bool)
enable_turbo_mode = optional(bool)
enable_uefi_networking = optional(bool)
performance_monitoring_unit = optional(string)
threads_per_core = optional(number)
visible_core_count = optional(number)
}))
allow_stopping_for_update = optional(bool, true)
deletion_protection = optional(bool, false)
max_run_duration = optional(object({
@@ -312,11 +320,26 @@ variable "options" {
termination_action = null
}
validation {
condition = (var.options.termination_action == null
condition = (
var.options.termination_action == null
||
contains(["STOP", "DELETE"], coalesce(var.options.termination_action, "1")))
contains(["STOP", "DELETE"], coalesce(var.options.termination_action, "1"))
)
error_message = "Allowed values for options.termination_action are 'STOP', 'DELETE' and null."
}
validation {
condition = (
try(var.options.advanced_machine_features.performance_monitoring_unit, null) == null
||
contains(["ARCHITECTURAL", "ENHANCED", "STANDARD"], coalesce(
try(
var.options.advanced_machine_features.performance_monitoring_unit, null
), "-"
)
)
)
error_message = "Allowed values for options.advanced_machine_features.performance_monitoring_unit are ARCHITECTURAL', 'ENHANCED', 'STANDARD' and null."
}
}
variable "project_id" {