Fn::Indent

Updated at:

The built-in function Fn::Indent adjusts the indentation format of a string.

Function declaration

  • JSON

    {
      "Fn::Indent": [
        "String",
        "Level",
        "Size",
        "IndentFirstLine"
      ]
     }
  • YAML

    Fn::Indent:
      - String
      - Level
      - Size
      - IndentFirstLine

Parameters

  • String: the string whose indentation format you want to adjust.

  • Level: the indentation level. Valid values: 0 to 20.

  • Size: the indentation size. This parameter is optional. Valid values: 0 to 4. Default value: 2. A value of 2 indicates that the content at each level is indented by two spaces.

  • IndentFirstLine: Specifies whether to indent the first line of the string. This parameter is optional. The default value is `True`.

Return value

Returns the string with the modified indentation.

Examples

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  p1:
    Default: |-
      [client]
      port=3306
      password=123
    Type: String
Outputs:
  result:
    Value:
      'Fn::Sub':
        - |
          data:
          ${p1}
        - p1:
            'Fn::Indent':
              - Ref: p1
              - 1

Result before the format is adjusted

data:
[client]
port=3306
password=123

Result after the format is adjusted

data:
  [client]
  port=3306
  password=123

Supported functions

Ref