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.06k stars 977 forks source link

terragrunt catalog support for module monorepo #2877

Closed tinder-tder closed 1 month ago

tinder-tder commented 10 months ago

Describe the solution you'd like Support module monorepos when using catalog command (example: https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example/tree/master)

Currently only polyrepos are supported or if the repo root has a modules subdir in it.

running a catalog command against a mono repo without a path will fail because it it has no .tf files in the root

% tg catalog https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example/                      
DEBU[0000] Terragrunt Version: 0.54.1                   
INFO[0000] Cloning repository "https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example/" to temprory directory "/var/folders/74/0smsj_5x54d36ybdpbf_xm0w0000gn/T/catalog-2858041464" 
DEBU[0001] Parsing git config "/var/folders/74/0smsj_5x54d36ybdpbf_xm0w0000gn/T/catalog-2858041464/.git/config" 
DEBU[0001] Remote url: "https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example.git" for repo: "/var/folders/74/0smsj_5x54d36ybdpbf_xm0w0000gn/T/catalog-2858041464" 
ERRO[0001] specified repository "https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example/" does not contain modules 
ERRO[0001] Unable to determine underlying exit code, so Terragrunt will exit with error code 1 

adding a full path to a module subdir will fail because its not a "git repo"

% tg catalog https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example/mysql
DEBU[0000] Terragrunt Version: 0.54.1                   
INFO[0000] Cloning repository "https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example/mysql" to temprory directory "/var/folders/74/0smsj_5x54d36ybdpbf_xm0w0000gn/T/catalog-571873603" 
ERRO[0001] the specified path "/var/folders/74/0smsj_5x54d36ybdpbf_xm0w0000gn/T/catalog-571873603" is not a git repository 
ERRO[0001] Unable to determine underlying exit code, so Terragrunt will exit with error code 1 

There should be a way to specify a repo root and automatically parse all subdirectories in the same way a modules dir would be processed.

Describe alternatives you've considered reorganizing our current IAC module repo is doable but would involve updating all references elsewhere to match the new module path

Dudesons commented 7 months ago

I just discover this command and want to try it in my mono repo but I discover this issue. I would like to add another thing in this kind of setup, it would be nice if we can specify a path to our modules without the need to have a git repository because in some cases the git repo contain more than iac code or we are mounting the code in a container with a docker compose/dagger/...

Is it something possible in the future or the git repository is mandatory ?

liukch commented 7 months ago

Yes, why there must be a modules subfolder in git repo?

arichtman-srt commented 6 months ago

Similar issue - relative paths within the same repo fail saying "not a git repository". We would like to keep our modules in the same repository, just under terraform/modules, not the root + modules

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.