E o vencedor é: index(list, element)
variable "domains" {
type = "list"
default = [
"tftesting.io",
"tftesting.co",
]
}
output "co_index" {
value = "${index(var.domains, "tftesting.co")}"
}
output "io_index" {
value = "${index(var.domains, "tftesting.io")}"
}
O resultado final:
$ terraform apply
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
co_index = 1
io_index = 0