Terraform if语句,带true或false
我需要准备if声明。我想知道什么是最好的解决办法Terraform if语句,带true或false,terraform,Terraform,我需要准备if声明。我想知道什么是最好的解决办法 locals { prod_ingress_certyficate = "${prod_ingress_certyficate == "true" ? var.prod_cert : var.test_cert}" } 这是正确的方法吗?如果变量为true,则使用prod\u cert;如果为false,则使用test\u cert。在定义前,不能引用prod\u entres\u certyfic
locals {
prod_ingress_certyficate = "${prod_ingress_certyficate == "true" ? var.prod_cert : var.test_cert}"
}
这是正确的方法吗?如果变量为true,则使用prod\u cert;如果为false,则使用test\u cert。在定义前,不能引用
prod\u entres\u certyficate
。但是,您可以创建一个名为prod\u incress\u certyficate
的变量,然后在您的条件下在locals
中使用该变量:
variable "prod_cert" {
default = "prod_cert"
}
variable "test_cert" {
default = "test_cert"
}
variable "prod_ingress_certyficate" {
default = true
}
locals {
prod_ingress_certyficate = var.prod_ingress_certyficate == true ? var.prod_cert : var.test_cert
}
output "test" {
value = local.prod_ingress_certyficate
}