|
|
|
|
@ -47,7 +47,7 @@ There are also two special escape sequences that do not use backslashes:
|
|
|
|
|
|
|
|
|
|
## Heredoc Strings
|
|
|
|
|
|
|
|
|
|
Terraform also supports a "heredoc" style of string literal inspired by Unix
|
|
|
|
|
Terraform supports a "heredoc" style of string literal inspired by Unix
|
|
|
|
|
shell languages, which allows multi-line strings to be expressed more clearly.
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
@ -74,20 +74,25 @@ In the above example, `EOT` is the identifier selected. Any identifier is
|
|
|
|
|
allowed, but conventionally this identifier is in all-uppercase and begins with
|
|
|
|
|
`EO`, meaning "end of". `EOT` in this case stands for "end of text".
|
|
|
|
|
|
|
|
|
|
### Generating JSON or YAML
|
|
|
|
|
<Highlight>
|
|
|
|
|
|
|
|
|
|
Don't use "heredoc" strings to generate JSON or YAML. Instead, use
|
|
|
|
|
[the `jsonencode` function](/terraform/language/functions/jsonencode) or
|
|
|
|
|
[the `yamlencode` function](/terraform/language/functions/yamlencode) so that Terraform
|
|
|
|
|
can be responsible for guaranteeing valid JSON or YAML syntax.
|
|
|
|
|
|
|
|
|
|
<CodeBlockConfig>
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
example = jsonencode({
|
|
|
|
|
a = 1
|
|
|
|
|
b = "hello"
|
|
|
|
|
})
|
|
|
|
|
example = jsonencode({
|
|
|
|
|
a = 1
|
|
|
|
|
b = "hello"
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</CodeBlockConfig>
|
|
|
|
|
</Highlight>
|
|
|
|
|
|
|
|
|
|
### Indented Heredocs
|
|
|
|
|
|
|
|
|
|
The standard heredoc form (shown above) treats all space characters as literal
|
|
|
|
|
|