I need to check the value that exists in a variable or not and based on that I need to create resources.
If value_list
doesn't have these values('abc','def','ghi')
it should not create the resource.
What I'm trying here is:
- Converting the string variable to list
- Check that list is having values 'abc' or 'def' or 'ghi'. If
value_list
contains any one of the values then proceed with the next steps to create resources. - If
value_list
doesn't have thesevalues('abc','def','ghi')
it should not create the resource.
variables.tf
variable "value_list" {
default = "abc,def,ghi"
type= string
}
resource.tf
resource "azurerm_kubernetes_cluster_node_pool" "user" {
value_list = ${split(",", var.value_list)}
count = "${contains(value_list,"abc") ? 1 : 0 || contains(value_list,"def") ? 1 : 0 || contains(value_list,"ghi") ? 1 : 0
}
Error:
This character is not used within the language. Expected the start of an expression, but found an invalid expression token.
How to check if the value_list is having the desired value or not?