Reputation: 1
I have defined 3 different sizes in variable.tf as below
variable size {
description = "size of the disk"
type = number
}
variable size2 {
description = "size of the disk "
type = number
}
variable size3 {
description = "size of the disk "
type = number
}
variable drives {
description = "drive value (max=3)"
type = number
}
main.tf
drives=var.drives
size=var.size
size2=var.drives==2 ? var.size2:null
size3 =var.drives==3 ? var.size3:null
Therefore, I'm attempting to create or take input for size2 and size3 variable only when the values of the cloud drives are 2 and 3, respectively.
But even though I have set the cloud drivers variable to 1, the terraform plan
command still asks for all three different sizes as input.Since I'm new to Terraform World, could you kindly assist me with this?
Upvotes: 0
Views: 225
Reputation: 238209
terraform plan command still asks for all three different sizes
Because you did not provide any default values. Thus you have to provide all values for all these parameters. Just define some defaults:
variable size2 {
description = "size of the disk "
type = number
default = 0
}
variable size3 {
description = "size of the disk "
type = number
default = 0
}
Upvotes: 1