Files
opentf/website/docs/configuration/functions/fileexists.html.md
Nick Fagerlund 596e529602 website: Adopt a ton of pages into the "language" layout
As of this commit, that layout doesn't exist yet, but I'm isolating the one-line
changes to their own commit to try and keep your eyes from glazing over.
2020-10-26 18:19:26 -07:00

1.1 KiB

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
language fileexists - Functions - Configuration Language docs-funcs-file-file-exists The fileexists function determines whether a file exists at a given path.

fileexists Function

-> Note: This page is about Terraform 0.12 and later. For Terraform 0.11 and earlier, see 0.11 Configuration Language: Interpolation Syntax.

fileexists determines whether a file exists at a given path.

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
fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_content
  • file reads the contents of a file at a given path