Zachary Shilton 830140157d
website: remove obselete nav data (#10811)
* website: remove obselete sidebar_title frontmatter from docs

* website: bump to latest docs-page

* website: update plugin creation and registration docs

* website: fix broken links
2021-03-31 15:07:00 -04:00

36 lines
901 B
Plaintext

---
page_title: fileexists - Functions - Configuration Language
description: The fileexists function determines whether a file exists at a given path.
---
# `fileexists` Function
`fileexists` determines whether a file exists at a given path.
```hcl
fileexists(path)
```
Functions are evaluated during configuration parsing rather than at apply time,
so this function can only be used with files that are already present on disk
before Packer takes any actions.
This function works only with regular files. If used with a directory, FIFO,
or other special mode, it will return an error.
## Examples
```shell-session
> fileexists("${path.folder}/hello.txt")
true
```
```hcl
fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_content
```
## Related Functions
- [`file`](/docs/templates/hcl_templates/functions/file/file) reads the contents
of a file at a given path.