Terraform version: v0.13.0
I am trying to leverage the new variable validation functionality to validate an input variable based on another input variable, ‘amount’ which represents what the reserved count variable gets set to universally across all modules called in my particular deployment implementation:
variable "amount"{
default = 1
}
variable "domain-mappings" {
type = list(object({
http_c2_domain = string
}))
default = [
{
http_c2_domain ="awesomedomain.com"
}
]
validation {
condition=(
length(var.domain-mappings != var.amount)
)
error_message = "The amount of domain mappings must equal the amount of HTTP C2 deployments."
}
}
Given the error indictating that it is not currently supported:
Error: Invalid reference in variable validation
on aws_c2_http.tf line 54, in variable "domain-mappings":
54: length(var.domain-mappings != var.amount)
The condition for variable "domain-mappings" can only refer to the variable
itself, using var.domain-mappings.
Is there any other way to accomplish my goal of applying the count / amount validation? I tried hacking it in through local, with no luck.
Thanks so much for any assistance.
Joe