mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
migrate docs to mdx
This commit is contained in:
35
website/docs/language/functions/fileexists.mdx
Normal file
35
website/docs/language/functions/fileexists.mdx
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
page_title: fileexists - Functions - Configuration Language
|
||||
description: The fileexists function determines whether a file exists at a given path.
|
||||
sidebar_title: fileexists
|
||||
---
|
||||
|
||||
# `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 Terraform 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
|
||||
|
||||
```
|
||||
> fileexists("${path.module}/hello.txt")
|
||||
true
|
||||
```
|
||||
|
||||
```hcl
|
||||
fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_content
|
||||
```
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`file`](/language/functions/file) reads the contents of a file at a given path
|
||||
Reference in New Issue
Block a user