2018-05-07 03:32:16 +02:00
|
|
|
---
|
2020-08-15 03:51:06 +02:00
|
|
|
layout: "language"
|
2018-12-20 05:35:11 +01:00
|
|
|
page_title: "split - Functions - Configuration Language"
|
2018-05-07 03:32:16 +02:00
|
|
|
sidebar_current: "docs-funcs-string-split"
|
|
|
|
description: |-
|
|
|
|
The split function produces a list by dividing a given string at all
|
2019-03-21 20:20:29 +01:00
|
|
|
occurrences of a given separator.
|
2018-05-07 03:32:16 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# `split` Function
|
|
|
|
|
2019-01-17 01:33:57 +01:00
|
|
|
-> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
|
|
|
|
earlier, see
|
|
|
|
[0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
|
|
|
|
|
2019-03-21 20:20:29 +01:00
|
|
|
`split` produces a list by dividing a given string at all occurrences of a
|
2018-05-07 03:32:16 +02:00
|
|
|
given separator.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
split(separator, string)
|
|
|
|
```
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```
|
|
|
|
> split(",", "foo,bar,baz")
|
|
|
|
[
|
|
|
|
"foo",
|
|
|
|
"bar",
|
|
|
|
"baz",
|
|
|
|
]
|
|
|
|
> split(",", "foo")
|
|
|
|
[
|
|
|
|
"foo",
|
|
|
|
]
|
|
|
|
> split(",", "")
|
|
|
|
[
|
|
|
|
"",
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Related Functions
|
|
|
|
|
|
|
|
* [`join`](./join.html) performs the opposite operation: producing a string
|
|
|
|
joining together a list of strings with a given separator.
|