跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

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 ​

shellsession
> fileexists("${path.folder}/hello.txt")
true
hcl
fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_content
  • file reads the contents of a file at a given path.

基于 MPL-2.0 许可证发布。