Skip to content

Commit

Permalink
terraform, azure: add node_pools variable validation
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Jan 11, 2024
1 parent d6d89f5 commit d0ad3a2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion terraform/azure/projects/utoronto.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ node_pools = {
},
],

dask : []
dask : [],
}
41 changes: 30 additions & 11 deletions terraform/azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,43 @@ variable "ssh_pub_key" {
}

variable "node_pools" {
type = map(list(object({
name : string,
vm_size : string,
os_disk_size_gb : optional(number, 100),
kubelet_disk_type : optional(string, "Temporary"),
min : number,
max : number,
labels : optional(map(string), {}),
taints : optional(list(string), []),
kubernetes_version : optional(string, ""),
})))
type = map(
list(
object({
name : string,
vm_size : string,
os_disk_size_gb : optional(number, 100),
kubelet_disk_type : optional(string, "Temporary"),
min : number,
max : number,
labels : optional(map(string), {}),
taints : optional(list(string), []),
kubernetes_version : optional(string, ""),
})
)
)
description = <<-EOT
Node pools to create to be listed under the keys 'core', 'user', and 'dask'.
There should be exactly one core node pool. The core node pool is given a
special treatment by being listed directly in the cluster resource's
'default_node_pool' field.
EOT

validation {
condition = length(var.node_pools["core"]) == 1
error_message = "The core node pool is mapped to the cluster resource's `default_node_pool`, due to this we require exactly one core node pool to be specified."
}

validation {
condition = length(setsubtract(keys(var.node_pools), ["core", "user", "dask"])) == 0
error_message = "Only three kinds of node pools supported: 'core', 'user', and 'dask'."
}

validation {
condition = length(setintersection(keys(var.node_pools), ["core", "user", "dask"])) == 3
error_message = "All three kinds of node pools ('core', 'user', and 'dask') must be declared, even if they are empty lists of node pools."
}
}

variable "create_service_principal" {
Expand Down

0 comments on commit d0ad3a2

Please sign in to comment.