This validation block works for a single input variable.
variable "mytestname" {
validation {
condition = length(regexall("test$", var.mytestname)) > 0
error_message = "Should end in test"
}
}
I need it to work inside a for_each - or have some workaround to accomplish this. The issue is that there is a restriction on the condition statement - the condition HAS to take in the input variable itself (i.e. - it cannot accept an each.value)
variable "mytestnames" {
listnames = split(",",var.mytestnames)
for_each = var.listnames
validation {
condition = length(regexall("test$", each.value)) > 0
error_message = "Should end in test"
}
}
The above snippet does not work. I need a way I can iterate over a list of values and validate each of them. It looks like the newly introduced 'validation block' does not work on lists of input variables. There must be a way to do this without a validation block...??