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

     1  ---
     2  page_title: filebase64 - Functions - Configuration Language
     3  description: |-
     4    The filebase64 function reads the contents of the file at the given path and
     5    returns them as a base64-encoded string.
     6  ---
     7  
     8  # `filebase64` Function
     9  
    10  `filebase64` reads the contents of a file at the given path and returns them as
    11  a base64-encoded string.
    12  
    13  ```hcl
    14  filebase64(path)
    15  ```
    16  
    17  The result is a Base64 representation of the raw bytes in the given file.
    18  Strings in the Terraform language are sequences of Unicode characters, so
    19  Base64 is the standard way to represent raw binary data that cannot be
    20  interpreted as Unicode characters. Resource types that operate on binary
    21  data will accept this data encoded in Base64, thus avoiding the need to
    22  decode the result of this function.
    23  
    24  Terraform uses the "standard" Base64 alphabet as defined in
    25  [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
    26  
    27  This function can be used only with functions that already exist as static
    28  files on disk at the beginning of a Terraform run. Language functions do not
    29  participate in the dependency graph, so this function cannot be used with
    30  files that are generated dynamically during a Terraform operation.
    31  
    32  ## Examples
    33  
    34  ```
    35  > filebase64("${path.module}/hello.txt")
    36  SGVsbG8gV29ybGQ=
    37  ```
    38  
    39  ## Related Functions
    40  
    41  * [`file`](/language/functions/file) also reads the contents of a given file,
    42    but interprets the data as UTF-8 text and returns the result directly
    43    as a string, without any further encoding.
    44  * [`base64decode`](/language/functions/base64decode) can decode a Base64 string representing
    45    bytes in UTF-8, but in practice `base64decode(filebase64(...))` is equivalent
    46    to the shorter expression `file(...)`.