In Terraform, I want a user to enter values for a variable (type list) without having to worry too much about the syntax for a list variable. For example, Terraform requires the following syntax for lists:
Enter value: ["value1", "value2", "value3"]
It would be nice if the user just needed to enter a comma separated list without having to worry about adding quotations and the brackets. For example:
Enter value: value1, value2, value3
From the comma separated string, I would like to convert it to type list with the correct syntax.
My current code looks like this, I don't think I am even close to figuring it out. Any help is appreciated!
variable "subnetNames" {
description = "Enter value:"
default = "value1, value2, value3"
}
output "test" {
value = "${join(",", list("[", var.subnetNames, "]"))}"
}