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