You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
terraform/website/docs/language/functions/indent.mdx

42 lines
1.9 KiB

---
page_title: indent - Functions - Configuration Language
description: |-
The indent function adds spaces to the beginning of each line but the first in a multi-line string.
---
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
> [!IMPORTANT]
> **Documentation Update:** Product documentation previously located in `/website` has moved to the [`hashicorp/web-unified-docs`](https://github.com/hashicorp/web-unified-docs) repository, where all product documentation is now centralized. Please make contributions directly to `web-unified-docs`, since changes to `/website` in this repository will not appear on developer.hashicorp.com.
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
# `indent` function reference
This topic provides reference information about the `indent` function.
You can use the `indent` function to add indentation to the beginning of each line, except the first, in a multi-line string.
## Introduction
The `indent` function adds a specified number of spaces to the beginning of each line in a multi-line string, except for the first line.
You can use the `indent` function to help ensure that complex strings are properly formatted, consistent, and readable.
The function can be especially useful when you work with YAML, JSON, Kubernetes, or other formats that require complex, structured text.
## Syntax
Use the `indent` function with the following syntax:
```hcl
indent(num_spaces, string)
```
- The first argument is numeric. It specifies the number of spaces you want to add to each line except the first.
- The second argument is a string. It specifies the multi-line string to which you want to add spaces.
In the following example, the `indent` function adds two spaces to the beginning of each line of the `description` variable to make it easier to read:
```hcl
output "formatted_description" {
value = indent(2, var.description)
}
```