Skip to content
Terrateam

Ignoring a Directory

In some cases, you may want to prevent Terrateam from running plans or applies within certain directories or files in your repository.

Why ignore directories or files?
This is especially useful for:

  • Directories with Terraform modules that are not meant to be deployed directly (for example, shared modules or templates).
  • Supporting files or folders that match Terraform file patterns (like .tf), but should not trigger infrastructure changes.

To ignore a directory in Terrateam, add it to the dirs section in your .terrateam/config.yml file and set when_modified.file_patterns to an empty list.

Example: Ignore the docs directory

dirs:
docs:
when_modified:
file_patterns: []

Changes to files in the docs directory will not trigger any plans or applies.

If you have a directory containing Terraform modules (for example, modules/), and you do not want changes in these modules to trigger runs directly, you can ignore the entire directory:

dirs:
modules:
when_modified:
file_patterns: []

Keys of the dirs section always name directories. A key that matches a file resolves to the directory that contains the file, so file_patterns: [] under such a key disables the whole directory, not just the file.

To ignore specific files, keep the directory enabled and exclude the files from file_patterns with a ! pattern. For example, to ignore foobar/generated.tf while still planning on the other files in foobar:

Example: Ignore a specific file

dirs:
foobar:
when_modified:
file_patterns: ["${DIR}/*.tf", "${DIR}/*.tfvars", "!${DIR}/generated.tf"]
dirs:
foobar:
when_modified:
file_patterns: ["${DIR}/*.tf", "${DIR}/*.tfvars", "!${DIR}/dev.*.tfvars"]

You can use glob patterns as dirs keys to ignore every directory matching a pattern. For example, to ignore all directories under test/:

dirs:
test/**:
when_modified:
file_patterns: []

To ignore files ending in .example.tf in every directory, set a top-level when_modified with an exclusion. The top-level file_patterns applies to every directory that does not override it:

when_modified:
file_patterns: ["${DIR}/*.tf", "${DIR}/*.tfvars", "!${DIR}/*.example.tf"]
  • Use precise patterns to avoid unintentionally ignoring important infrastructure code.
  • Review the Dirs configuration reference for more on glob patterns and advanced matching.
  • Remember that ignoring a directory or file means no plans or applies will be triggered for changes within it.

If you need to ignore more complex patterns or have questions about matching behavior, see the Globs section in the configuration reference.