terraform { required_version = ">= 1.0" required_providers { talos = { source = "siderolabs/talos" version = "~> 0.4" } } } # Load variables from a .tfvars file variable "cluster_name" { description = "The name of the Talos cluster" type = string default = "evolved-npcs-cluster" } variable "memory_mb" { description = "Memory for each VM in MB" type = number default = 2048 } variable "vcpu_count" { description = "Number of vCPUs for each VM" type = number default = 2 } variable "talos_version" { description = "The version of Talos to use" type = string default = "v1.11.1" } locals { # Generate unique cluster name each time unique_cluster_name = "${var.cluster_name}-${random_id.cluster_suffix.hex}" } resource "random_id" "cluster_suffix" { byte_length = 4 } resource "null_resource" "talos_cluster" { triggers = { cluster_name = local.unique_cluster_name memory_mb = var.memory_mb vcpu_count = var.vcpu_count talos_version = var.talos_version config_hash = sha1(join("", [ local.unique_cluster_name, tostring(var.memory_mb), tostring(var.vcpu_count), var.talos_version, filesha1("${path.module}/cleanup.sh") # Recreate if cleanup script changes ])) } # Download Talos kernel and initramfs provisioner "local-exec" { command = <