terraform/website/docs/configuration/functions/fileset.html.md

1.2 KiB

layout page_title sidebar_current description
functions fileset - Functions - Configuration Language docs-funcs-file-file-set The fileset function enumerates a set of regular file names given a pattern.

fileset Function

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

fileset enumerates a set of regular file names given a pattern.

fileset(pattern)

Supported pattern matches:

  • * - matches any sequence of non-separator characters
  • ? - matches any single non-separator character
  • [RANGE] - matches a range of characters
  • [^RANGE] - matches outside the range of characters

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.

Examples

> fileset("${path.module}/*.txt")
[
  "path/to/module/hello.txt",
  "path/to/module/world.txt",
]
resource "example_thing" "example" {
  for_each = fileset("${path.module}/files/*")

  # other configuration using each.value
}