github.com/jaredpalmer/terraform@v1.1.0-alpha20210908.0.20210911170307-88705c943a03/website/docs/language/functions/formatlist.html.md (about) 1 --- 2 layout: "language" 3 page_title: "formatlist - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-string-formatlist" 5 description: |- 6 The formatlist function produces a list of strings by formatting a number of 7 other values according to a specification string. 8 --- 9 10 # `formatlist` Function 11 12 `formatlist` produces a list of strings by formatting a number of other 13 values according to a specification string. 14 15 ```hcl 16 formatlist(spec, values...) 17 ``` 18 19 The specification string uses 20 [the same syntax as `format`](./format.html#specification-syntax). 21 22 The given values can be a mixture of list and non-list arguments. Any given 23 lists must be the same length, which decides the length of the resulting list. 24 25 The list arguments are iterated together in order by index, while the non-list 26 arguments are used repeatedly for each iteration. The format string is evaluated 27 once per element of the list arguments. 28 29 ## Examples 30 31 ``` 32 > formatlist("Hello, %s!", ["Valentina", "Ander", "Olivia", "Sam"]) 33 [ 34 "Hello, Valentina!", 35 "Hello, Ander!", 36 "Hello, Olivia!", 37 "Hello, Sam!", 38 ] 39 > formatlist("%s, %s!", "Salutations", ["Valentina", "Ander", "Olivia", "Sam"]) 40 [ 41 "Salutations, Valentina!", 42 "Salutations, Ander!", 43 "Salutations, Olivia!", 44 "Salutations, Sam!", 45 ] 46 ``` 47 48 ## Related Functions 49 50 * [`format`](./format.html) defines the specification syntax used by this 51 function and produces a single string as its result.