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.
How to Ignore a Directory
Section titled “How to Ignore a Directory”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.
Ignoring Module Directories
Section titled “Ignoring Module Directories”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: []Ignoring Specific Files
Section titled “Ignoring Specific Files”You can also ignore specific files by using their path as a key in the dirs section and setting file_patterns to an empty list:
Example: Ignore a specific file
dirs: foobar.tf: when_modified: file_patterns: []dirs: "dev.*.tfvars": when_modified: file_patterns: []Advanced: Ignoring by Pattern
Section titled “Advanced: Ignoring by Pattern”You can use glob patterns to ignore files or directories matching a pattern. For example, to ignore all files in a test/ directory:
dirs: test/**: when_modified: file_patterns: []Or to ignore all files ending in .example.tf:
dirs: "**/*.example.tf": when_modified: file_patterns: []Best Practices
Section titled “Best Practices”- 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.