github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/base64encode.html.md (about)

     1  ---
     2  layout: "functions"
     3  page_title: "base64encode - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-encoding-base64encode"
     5  description: |-
     6    The base64encode function applies Base64 encoding to a string.
     7  ---
     8  
     9  # `base64encode` Function
    10  
    11  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    12  earlier, see
    13  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    14  
    15  `base64encode` applies Base64 encoding to a string.
    16  
    17  Terraform uses the "standard" Base64 alphabet as defined in
    18  [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
    19  
    20  Strings in the Terraform language are sequences of unicode characters rather
    21  than bytes, so this function will first encode the characters from the string
    22  as UTF-8, and then apply Base64 encoding to the result.
    23  
    24  The Terraform language applies Unicode normalization to all strings, and so
    25  passing a string through `base64decode` and then `base64encode` may not yield
    26  the original result exactly.
    27  
    28  While we do not recommend manipulating large, raw binary data in the Terraform
    29  language, Base64 encoding is the standard way to represent arbitrary byte
    30  sequences, and so resource types that accept or return binary data will use
    31  Base64 themselves, and so this function exists primarily to allow string
    32  data to be easily provided to resource types that expect Base64 bytes.
    33  
    34  ## Examples
    35  
    36  ```
    37  > base64encode("Hello World")
    38  SGVsbG8gV29ybGQ=
    39  ```
    40  
    41  ## Related Functions
    42  
    43  * [`base64decode`](./base64decode.html) performs the opposite operation,
    44    decoding Base64 data and interpreting it as a UTF-8 string.
    45  * [`base64gzip`](./base64gzip.html) applies gzip compression to a string
    46    and returns the result with Base64 encoding all in one operation.
    47  * [`filebase64`](./filebase64.html) reads a file from the local filesystem
    48    and returns its raw bytes with Base64 encoding, without creating an
    49    intermediate Unicode string.