Skip to content

Support configurable module directory in Terragrunt Catalog #4632

@moustafaatef74

Description

@moustafaatef74

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

  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 catalog block, such as module_paths or module_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.

Metadata

Metadata

Assignees

Labels

contributions-requestedRequesting contributions from the communityenhancementNew feature or requestpreservedPreserved issues never go stale

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions