- OpenTofu 语言
- 函数
- fileexists
fileexists
函数
fileexists
确定文件是否存在于给定路径。
fileexists(path)
函数在配置解析期间而不是在应用时进行评估,因此此函数只能用于 OpenTofu 执行任何操作之前已存在于磁盘上的文件。
此函数仅适用于普通文件。如果与目录、FIFO 或其他特殊模式一起使用,它将返回错误。
示例
> fileexists("${path.module}/hello.txt")
true
fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_content
相关函数
file
读取给定路径下文件的內容