You can use terraform compact() function to remove an empty string from a list. compact() takes a list of strings and returns a new list with any empty string elements removed.
Syntax: compact(list)
Example:
1 2 3 4 5 6 7 |
## Open terraform console terraform console ## Remove an empty string from a list compact(["a", "", "b", "c"]) ## returns ## ["a","b","c"] |