Terraform 任何真实条件
Terraform anytrue condition
我在 *.tfvars 中指定了一个实例类型变量,我正在尝试合并使用“anytrue”函数,但是我无法让它工作。目的是为用户提供四种实例类型的选择,并且它们是唯一被接受的实例类型
variables.tf
variable "myinstance" {
type = list(string)
description "Select one of the following instance types - t3.medium, t3.large, t3.xlarge
or t3.2xlarge"
validation {
condition = anytrue (["t3.medium","t3.large","t3.xlarge","t3.2xlarge"],var.myinstance)
error_message = "Please select a valid instance type."
}
default = []
}
*.tfvars 文件 = ["t3.medium"]
错误信息:
var.myinstance will be known only after apply.
Function "anytrue" expects only 1 argument(s)
我认为最好的方法是使用 setintersection:
condition = length(setintersection(["t3.medium","t3.large","t3.xlarge","t3.2xlarge"], var.myinstance)) >= length(var.myinstance)
我在 *.tfvars 中指定了一个实例类型变量,我正在尝试合并使用“anytrue”函数,但是我无法让它工作。目的是为用户提供四种实例类型的选择,并且它们是唯一被接受的实例类型
variables.tf
variable "myinstance" {
type = list(string)
description "Select one of the following instance types - t3.medium, t3.large, t3.xlarge
or t3.2xlarge"
validation {
condition = anytrue (["t3.medium","t3.large","t3.xlarge","t3.2xlarge"],var.myinstance)
error_message = "Please select a valid instance type."
}
default = []
}
*.tfvars 文件 = ["t3.medium"]
错误信息:
var.myinstance will be known only after apply.
Function "anytrue" expects only 1 argument(s)
我认为最好的方法是使用 setintersection:
condition = length(setintersection(["t3.medium","t3.large","t3.xlarge","t3.2xlarge"], var.myinstance)) >= length(var.myinstance)