github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/formatlist.html.md (about) 1 --- 2 layout: "functions" 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 -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and 13 earlier, see 14 [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html). 15 16 `formatlist` produces a list of strings by formatting a number of other 17 values according to a specification string. 18 19 ```hcl 20 formatlist(spec, values...) 21 ``` 22 23 The specification string uses 24 [the same syntax as `format`](./format.html#specification-syntax). 25 26 The given values can be a mixture of list and non-list arguments. Any given 27 lists must be the same length, which decides the length of the resulting list. 28 29 The list arguments are iterated together in order by index, while the non-list 30 arguments are used repeatedly for each iteration. The format string is evaluated 31 once per element of the list arguments. 32 33 ## Examples 34 35 ``` 36 > formatlist("Hello, %s!", ["Valentina", "Ander", "Olivia", "Sam"]) 37 [ 38 "Hello, Valentina!", 39 "Hello, Ander!", 40 "Hello, Olivia!", 41 "Hello, Sam!", 42 ] 43 > formatlist("%s, %s!", "Salutations", ["Valentina", "Ander", "Olivia", "Sam"]) 44 [ 45 "Salutations, Valentina!", 46 "Salutations, Ander!", 47 "Salutations, Olivia!", 48 "Salutations, Sam!", 49 ] 50 ``` 51 52 ## Related Functions 53 54 * [`format`](./format.html) defines the specification syntax used by this 55 function and produces a single string as its result.