gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.09k stars 981 forks source link

Terragrunt Catalog lists tofu test modules/helpers #3378

Open RBurot opened 2 months ago

RBurot commented 2 months ago

Describe the bug

When I launch terragrunt catalog command, all modules are presents including fixture module for testing

Steps To Reproduce

I write ready-to-use catalog for my team

I design a module and I implement test with opentofu test method https://opentofu.org/docs/cli/commands/test/

To do the endtoend test, I create a fixture module to have helpers (in the setup folder): ├── README.md ├── locals.tf ├── main.tf ├── outputs.tf ├── tests │   ├── main.tftest.hcl │   └── setup │   └── main.tf ├── variables.tf └── versions.tf

when I launch the terragrunt catalog command, the helper module for the test is listed

Expected behavior

I don't want to have fixtures or helpers modules listed or have a way to ignore helpers modules

Nice to haves

image

Versions

Additional context

the only workaround way I found is to externalize fixture or helpers test modules from root modules folder

josh-padnick commented 2 months ago

@yhakbar This is worth generally prioritizing. Let's also discuss this in more detail when we focus on the upcoming Catalog project in the roadmap.

yhakbar commented 2 months ago

@josh-padnick Sounds good. I think we can design something that works nicely to offer the ability to ignore modules from repos or something. I think a .terragrunt-catalog-exclude file might be the pattern that does this best.

@RBurot , FYI, Gruntwork TF module repos all include tests directories as well, but we don't run into this issue because we generally don't put modules at the root of the repo. They are generally nested into a modules directory so that they're isolated from content like CI/CD configurations, etc.

This might be another way to work around this issue pending of a first class way to ignore content in module repos.

RBurot commented 2 months ago

@yhakbar It's the same in my case. (the complete repo tree): image I had focus on one module because the problem is linked to the module tests included inside the module

I think the .terragrunt-catalog-exclude file could be a great solution.

For the moment, I think the best way to do the job is to externalize out of root modules folder the test helpers modules. And at the end, I think it's the best way to do to DRY the helpers module too.

josh-padnick commented 2 months ago

Just to throw another idea out there, we could also introduce a new configuration block (e.g. catalog) that allows you specify a RegEx of which directories you'd like to include in the list. I wonder if "opt in" works better here than "opt out".