@@ -52,7 +52,8 @@ variable "login" {
5252 be useful for e.g. separating nodes for ssh and Open Ondemand usage, or
5353 to define login nodes with different capabilities such as high-memory.
5454
55- Keys are names of groups.
55+ Keys are names of groups, and cannot be 'login', 'compute', 'control', or
56+ keys in the compute or additional_nodegroups variables.
5657 Values are a mapping as follows:
5758
5859 Required:
@@ -88,6 +89,25 @@ variable "login" {
8889 EOF
8990
9091 type = any
92+ validation {
93+ condition = length (setintersection (keys (var. login ), [" login" , " compute" , " control" ])) == 0
94+ error_message = <<- EOF
95+ Login nodegroup names cannot be 'login', 'compute' or 'control'. Invalid var.login key(s): ${ join (" , " , setintersection (keys (var. login ), [" login" , " compute" , " control" ]))} .
96+ EOF
97+ }
98+ validation {
99+ condition = length (distinct (concat (keys (var. login ), keys (var. compute ), keys (var. additional_nodegroups )))) == length (concat (keys (var. login ), keys (var. compute ), keys (var. additional_nodegroups )))
100+ error_message = <<- EOF
101+ Nodegroup names must be unique. Shared key(s) found in variables login, compute and/or additional_nodegroups: ${
102+ join (" , " , setunion (
103+ setintersection (keys (var. login ), keys (var. compute )),
104+ setintersection (keys (var. compute ), keys (var. additional_nodegroups )),
105+ setintersection (keys (var. additional_nodegroups ), keys (var. login ))
106+ ))
107+ }
108+ EOF
109+
110+ }
91111}
92112
93113variable "cluster_image_id" {
@@ -101,7 +121,8 @@ variable "compute" {
101121 Mapping defining homogenous groups of compute nodes. Groups are used
102122 in Slurm partition definitions.
103123
104- Keys are names of groups.
124+ Keys are names of groups, and cannot be 'compute', 'login', 'control', 'default'
125+ or keys in the login or additional_nodegroups variables.
105126 Values are a mapping as follows:
106127
107128 Required:
@@ -139,6 +160,12 @@ variable "compute" {
139160 EOF
140161
141162 type = any # can't do any better; TF type constraints can't cope with heterogeneous inner mappings
163+ validation {
164+ condition = length (setintersection (keys (var. compute ), [" login" , " compute" , " control" , " default" ])) == 0
165+ error_message = <<- EOF
166+ Compute nodegroup names cannot be 'compute', 'default', 'login' or 'control'. Invalid var.compute key(s): ${ join (" , " , setintersection (keys (var. compute ), [" login" , " compute" , " control" , " default" ]))} .
167+ EOF
168+ }
142169}
143170
144171# tflint-ignore: terraform_typed_variables
@@ -149,7 +176,8 @@ variable "additional_nodegroups" {
149176 These nodes are not in the compute or login inventory groups so they
150177 will not run slurmd.
151178
152- Keys are names of groups.
179+ Keys are names of groups and cannot be 'login', 'compute, 'control', or
180+ keys in the login or additional_nodegroups variables.
153181 Values are a mapping as for the "login" variable, with the addition of
154182 the optional entry:
155183
@@ -162,6 +190,13 @@ variable "additional_nodegroups" {
162190 - $cluster_name + '_' + $group_name
163191 - 'additional'
164192 EOF
193+ type = any # can't do any better; TF type constraints can't cope with heterogeneous inner mappings
194+ validation {
195+ condition = length (setintersection (keys (var. additional_nodegroups ), [" login" , " compute" , " control" ])) == 0
196+ error_message = <<- EOF
197+ Additional nodegroup names cannot be 'compute', 'login' or 'control'. Invalid var.additional_nodegroups key(s): ${ join (" , " , setintersection (keys (var. additional_nodegroups ), [" login" , " compute" , " control" ]))} .
198+ EOF
199+ }
165200}
166201
167202variable "environment_root" {
0 commit comments