You can use terraform csvdecode() function to convert CSV data into a map. csvdecode() decodes a string containing CSV-formatted data and produces a list of maps representing that data.
Syntax: csvdecode(csv_string)
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
## Open terraform console terraform console ## Convert a csv data into map csvdecode("a,b,c\n1,2,3\n4,5,6") ## returns ## [ ## { ## "a" = "1" ## "b" = "2" ## "c" = "3" ## }, ## { ## "a" = "4" ## "b" = "5" ## "c" = "6" ## }, ## ] |