website: doc replace

This commit is contained in:
Mitchell Hashimoto 2015-03-02 09:40:24 -08:00
parent 2f33a24385
commit 68e4d346be
1 changed files with 19 additions and 11 deletions

View File

@ -69,6 +69,13 @@ The supported built-in functions are:
* `concat(args...)` - Concatenates the values of multiple arguments into * `concat(args...)` - Concatenates the values of multiple arguments into
a single string. a single string.
* `element(list, index)` - Returns a single element from a list
at the given index. If the index is greater than the number of
elements, this function will wrap using a standard mod algorithm.
A list is only possible with splat variables from resources with
a count greater than one.
Example: `element(aws_subnet.foo.*.id, count.index)`
* `file(path)` - Reads the contents of a file into the string. Variables * `file(path)` - Reads the contents of a file into the string. Variables
in this file are _not_ interpolated. The contents of the file are in this file are _not_ interpolated. The contents of the file are
read as-is. read as-is.
@ -77,18 +84,19 @@ The supported built-in functions are:
only possible with splat variables from resources with a count only possible with splat variables from resources with a count
greater than one. Example: `join(",", aws_instance.foo.*.id)` greater than one. Example: `join(",", aws_instance.foo.*.id)`
* `split(delim, string)` - Splits the string previously created by `join`
back into a list. This is useful for pushing lists through module
outputs since they currently only support string values.
Example: `split(",", module.amod.server_ids)`
* `lookup(map, key)` - Performs a dynamic lookup into a mapping * `lookup(map, key)` - Performs a dynamic lookup into a mapping
variable. The `map` parameter should be another variable, such variable. The `map` parameter should be another variable, such
as `var.amis`. as `var.amis`.
* `element(list, index)` - Returns a single element from a list * `replace(string, search, replace)` - Does a search and replace on the
at the given index. If the index is greater than the number of given string. All instances of `search` are replaced with the value
elements, this function will wrap using a standard mod algorithm. of `replace`. If `search` is wrapped in forward slashes, it is treated
A list is only possible with splat variables from resources with as a regular expression. If using a regular expression, `replace`
a count greater than one. can reference subcaptures in the regular expression by using `$n` where
Example: `element(aws_subnet.foo.*.id, count.index)` `n` is the index or name of the subcapture. If using a regular expression,
the syntax conforms to the [re2 regular expression syntax](https://code.google.com/p/re2/wiki/Syntax).
* `split(delim, string)` - Splits the string previously created by `join`
back into a list. This is useful for pushing lists through module
outputs since they currently only support string values.
Example: `split(",", module.amod.server_ids)`