From b091fc213cde690d9ddc9c1f3821103ea3ed2fef Mon Sep 17 00:00:00 2001 From: Philippe Boneff Date: Tue, 20 Oct 2026 21:21:16 +0000 Subject: [PATCH] make number of VMs customizable --- deployment/modules/gcp/gce/tesseract/main.tf | 2 +- .../tests/variables_validation.tftest.hcl | 40 +++++++++++++++++++ .../modules/gcp/gce/tesseract/variables.tf | 12 ++++++ deployment/modules/gcp/tesseract/gce/main.tf | 1 + .../modules/gcp/tesseract/gce/variables.tf | 12 ++++++ 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/deployment/modules/gcp/gce/tesseract/main.tf b/deployment/modules/gcp/gce/tesseract/main.tf index 6af7dc130..7b23a4178 100644 --- a/deployment/modules/gcp/gce/tesseract/main.tf +++ b/deployment/modules/gcp/gce/tesseract/main.tf @@ -268,7 +268,7 @@ resource "google_compute_region_instance_group_manager" "instance_group_manager" } base_instance_name = var.base_name - target_size = "3" + target_size = var.num_vms update_policy { type = "PROACTIVE" diff --git a/deployment/modules/gcp/gce/tesseract/tests/variables_validation.tftest.hcl b/deployment/modules/gcp/gce/tesseract/tests/variables_validation.tftest.hcl index 655935e62..3224f4fcd 100644 --- a/deployment/modules/gcp/gce/tesseract/tests/variables_validation.tftest.hcl +++ b/deployment/modules/gcp/gce/tesseract/tests/variables_validation.tftest.hcl @@ -148,3 +148,43 @@ run "invalid_dates_not_after_limit_lowercase" { var.not_after_limit, ] } + +run "valid_num_vms" { + command = plan + + variables { + num_vms = 4 + } +} + +run "valid_num_vms_zero" { + command = plan + + variables { + num_vms = 0 + } +} + +run "invalid_num_vms_negative" { + command = plan + + variables { + num_vms = -1 + } + + expect_failures = [ + var.num_vms, + ] +} + +run "invalid_num_vms_float" { + command = plan + + variables { + num_vms = 2.5 + } + + expect_failures = [ + var.num_vms, + ] +} diff --git a/deployment/modules/gcp/gce/tesseract/variables.tf b/deployment/modules/gcp/gce/tesseract/variables.tf index d9e8bd460..728662bd4 100644 --- a/deployment/modules/gcp/gce/tesseract/variables.tf +++ b/deployment/modules/gcp/gce/tesseract/variables.tf @@ -39,6 +39,18 @@ variable "machine_type" { default = "n2-standard-4" } +variable "num_vms" { + description = "Number of VM instances to run in the regional managed instance group" + type = number + default = 3 + nullable = false + + validation { + condition = var.num_vms >= 0 && floor(var.num_vms) == var.num_vms + error_message = "num_vms must be a non-negative integer." + } +} + variable "bucket" { description = "Log GCS bucket" type = string diff --git a/deployment/modules/gcp/tesseract/gce/main.tf b/deployment/modules/gcp/tesseract/gce/main.tf index 901ff1491..9e549b03b 100644 --- a/deployment/modules/gcp/tesseract/gce/main.tf +++ b/deployment/modules/gcp/tesseract/gce/main.tf @@ -34,6 +34,7 @@ module "gce" { docker_repo = var.docker_repo server_docker_image = var.server_docker_image machine_type = var.machine_type + num_vms = var.num_vms not_after_start = var.not_after_start not_after_limit = var.not_after_limit bucket = module.storage.log_bucket.id diff --git a/deployment/modules/gcp/tesseract/gce/variables.tf b/deployment/modules/gcp/tesseract/gce/variables.tf index 01c4909dd..a8e9d332e 100644 --- a/deployment/modules/gcp/tesseract/gce/variables.tf +++ b/deployment/modules/gcp/tesseract/gce/variables.tf @@ -57,6 +57,18 @@ variable "machine_type" { default = "n2-standard-4" } +variable "num_vms" { + description = "Number of VM instances to run in the regional managed instance group" + type = number + default = 3 + nullable = false + + validation { + condition = var.num_vms >= 0 && floor(var.num_vms) == var.num_vms + error_message = "num_vms must be a non-negative integer." + } +} + variable "spanner_pu" { description = "Amount of Spanner processing units" type = number