github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/textencodebase64.mdx (about)

     1  ---
     2  page_title: textencodebase64 - Functions - Configuration Language
     3  description: >-
     4    The textencodebase64 function encodes the unicode characters in a given string
     5    using a
     6  
     7    specified character encoding, returning the result base64 encoded.
     8  ---
     9  
    10  # `textencodebase64` Function
    11  
    12  -> **Note:** This function is supported only in Terraform v0.14 and later.
    13  
    14  `textencodebase64` encodes the unicode characters in a given string using a
    15  specified character encoding, returning the result base64 encoded because
    16  Terraform language strings are always sequences of unicode characters.
    17  
    18  ```hcl
    19  substr(string, encoding_name)
    20  ```
    21  
    22  Terraform uses the "standard" Base64 alphabet as defined in
    23  [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
    24  
    25  The `encoding_name` argument must contain one of the encoding names or aliases
    26  recorded in
    27  [the IANA character encoding registry](https://www.iana.org/assignments/character-sets/character-sets.xhtml).
    28  Terraform supports only a subset of the registered encodings, and the encoding
    29  support may vary between Terraform versions. In particular Terraform supports
    30  `UTF-16LE`, which is the native character encoding for the Windows API and
    31  therefore sometimes expected by Windows-originated software such as PowerShell.
    32  
    33  Terraform also accepts the encoding name `UTF-8`, which will produce the same
    34  result as [`base64encode`](/language/functions/base64encode).
    35  
    36  ## Examples
    37  
    38  ```
    39  > textencodebase64("Hello World", "UTF-16LE")
    40  SABlAGwAbABvACAAVwBvAHIAbABkAA==
    41  ```
    42  
    43  ## Related Functions
    44  
    45  * [`textdecodebase64`](/language/functions/textdecodebase64) performs the opposite operation,
    46    decoding Base64 data and interpreting it as a particular character encoding.
    47  * [`base64encode`](/language/functions/base64encode) applies Base64 encoding of the UTF-8
    48    encoding of a string.
    49  * [`filebase64`](/language/functions/filebase64) reads a file from the local filesystem
    50    and returns its raw bytes with Base64 encoding, without creating an
    51    intermediate Unicode string.