mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-27 02:00:08 -04:00
Reference: https://github.com/hashicorp/terraform/issues/16697 Enumerates a set of regular file names from a given glob pattern. Implemented via the Go stdlib `path/filepath.Glob()` functionality. Notably, stdlib does not support `**` or `{}` extended patterns. See also: https://github.com/golang/go/issues/11862 To support the extended glob patterns, it will require adding a dependency on a third party library or adding our own matching code.
1.2 KiB
1.2 KiB
layout, page_title, sidebar_current, description
| 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
}