Reputation: 25409
I have a network
module with variable:
variable "subnetsCount" {
type = number
description = "Define amount of subnets between 2 min and 4 max"
validation {
condition = var.subnetsCount < 2 || var.subnetsCount > 4
error_message = "Variable subnetsCount should be between 2 and 4."
}
default = 2
}
I want to only allow a number value between 2 and 4. When I pass any value greater or smaller say 1 or 10 it doesn't throw any errors why?
1.For example I pass this to subnet:
module "network" {
source = "./network"
subnetsCount = 4
}
terraform apply
, yet no errors thrown.Upvotes: 3
Views: 935
Reputation: 238687
Your condition should be:
condition = var.subnetsCount >= 2 && var.subnetsCount <= 4
Upvotes: 3