-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Enhancement Request: Make module directory configurable in Terragrunt Catalog
Describe the enhancement
Currently, Terragrunt’s catalog service hardcodes the subdirectory scanned for Terraform modules as "modules" inside a repo. This limits usage when repositories use a different folder name, like tf-modules.
It would be very useful to make this configurable via the catalog block or a CLI flag, so users can specify the folder scanned inside the repo (e.g., tf-modules, terraform-modules, or anything else).
Additional context
- The problematic code is in
internal/services/catalog/module/repo.goat line 38:
modulesPaths = []string{"modules"}The module path is currently hardcoded, which restricts scanning to only that folder and excludes others.
Because this path cannot be configured, repositories that do not use the "modules" folder experience errors or no modules being detected.
Changes required
- Introduce a configurable option within the
catalogblock, such asmodule_pathsormodule_directory. - Modify the repo scanning logic to utilize this configuration option instead of the fixed "modules" path.
- Ensure backward compatibility by defaulting to "modules" if the option is not set.
Implications of the feature
- Enables Terragrunt catalog to support any repository structure without renaming folders.
- Increases flexibility and broadens the usability of Terragrunt catalog.
Alternatives considered
- Employ the double-slash URL syntax (e.g.,
//tf-modules) to target subdirectories, though this can cause issues if the subfolder isn’t a standalone Git repository. - Restructure repositories to use the "modules" directory name, which may not always be feasible or desirable.
Level of effort
Moderate — involves updates to both the catalog configuration handling and the scanning functionality in repo.go.
PoC (Proof of Concept)
- N/A
RFC Not Needed
- I have assessed the complexity of this enhancement and believe it does not require an RFC.