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

     1  ---
     2  page_title: fileexists - Functions - Configuration Language
     3  description: The fileexists function determines whether a file exists at a given path.
     4  ---
     5  
     6  # `fileexists` Function
     7  
     8  `fileexists` determines whether a file exists at a given path.
     9  
    10  ```hcl
    11  fileexists(path)
    12  ```
    13  
    14  Functions are evaluated during configuration parsing rather than at apply time,
    15  so this function can only be used with files that are already present on disk
    16  before Terraform takes any actions.
    17  
    18  This function works only with regular files. If used with a directory, FIFO,
    19  or other special mode, it will return an error.
    20  
    21  ## Examples
    22  
    23  ```
    24  > fileexists("${path.module}/hello.txt")
    25  true
    26  ```
    27  
    28  ```hcl
    29  fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_content
    30  ```
    31  
    32  ## Related Functions
    33  
    34  * [`file`](/language/functions/file) reads the contents of a file at a given path