繁体   English   中英

Terraform 任何真实情况

[英]Terraform anytrue condition

我有一个在 *.tfvars 中指定的实例类型变量,我正在尝试合并“anytrue”function 的使用,但是我无法让它工作。 目的是为用户提供四种实例类型的选择,并且它们是唯一被接受的实例类型

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM