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 command clones repos on every invocation #3532

Open tgeijg opened 1 week ago

tgeijg commented 1 week ago

Describe the bug

According to the Medium article on terragrunt catalog the command should only clone the configured repos on the first invocation.

Note: the catalog command will git clone the repos locally, so the first run may take a little while if you have lots of repos, but it should be much faster on all re-runs.

The docs are a little more vague as they just say the repos are cloned into a temporary folder.

Steps To Reproduce

Using the example from the Medium article above, if I add the catalog config to the root terragrunt file in our infra repo

catalog {
  urls = [
    "https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example",
    "https://github.com/gruntwork-io/terraform-aws-utilities",
    "https://github.com/gruntwork-io/terraform-kubernetes-namespace"
  ]
}

The results I'm seeing are that the repos are cloned (into the same temporary folder) on each catalog invocation.

❯ tg catalog
10:35:12.380 INFO   Cloning repository "git::https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example.git" to temporary directory "/var/folders/s3/zm9trzfs4cd6900ws1qhvfdh0000gp/T/catalog5a5f7a556b6a764d7757384d7a55516e437742456d616f6f413577/terragrunt-infrastructure-modules-example"
10:35:13.762 INFO   Found 5 modules in repository "https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example"
10:35:13.762 INFO   Cloning repository "git::https://github.com/gruntwork-io/terraform-aws-utilities.git" to temporary directory "/var/folders/s3/zm9trzfs4cd6900ws1qhvfdh0000gp/T/catalog4e5732674b627567715f364f6947554c45717a7a4132514766714d/terraform-aws-utilities"
10:35:16.613 INFO   Found 11 modules in repository "https://github.com/gruntwork-io/terraform-aws-utilities"
10:35:16.613 INFO   Cloning repository "git::https://github.com/gruntwork-io/terraform-kubernetes-namespace.git" to temporary directory "/var/folders/s3/zm9trzfs4cd6900ws1qhvfdh0000gp/T/catalog69625338504b4c684c66353434305f45594d486c74495a4d725959/terraform-kubernetes-namespace"
10:35:17.728 INFO   Found 4 modules in repository "https://github.com/gruntwork-io/terraform-kubernetes-namespace"
❯
❯ tg catalog
10:35:20.898 INFO   Cloning repository "git::https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example.git" to temporary directory "/var/folders/s3/zm9trzfs4cd6900ws1qhvfdh0000gp/T/catalog5a5f7a556b6a764d7757384d7a55516e437742456d616f6f413577/terragrunt-infrastructure-modules-example"
10:35:23.323 INFO   Found 5 modules in repository "https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example"
10:35:23.323 INFO   Cloning repository "git::https://github.com/gruntwork-io/terraform-aws-utilities.git" to temporary directory "/var/folders/s3/zm9trzfs4cd6900ws1qhvfdh0000gp/T/catalog4e5732674b627567715f364f6947554c45717a7a4132514766714d/terraform-aws-utilities"
10:35:27.127 INFO   Found 11 modules in repository "https://github.com/gruntwork-io/terraform-aws-utilities"
10:35:27.127 INFO   Cloning repository "git::https://github.com/gruntwork-io/terraform-kubernetes-namespace.git" to temporary directory "/var/folders/s3/zm9trzfs4cd6900ws1qhvfdh0000gp/T/catalog69625338504b4c684c66353434305f45594d486c74495a4d725959/terraform-kubernetes-namespace"
10:35:29.149 INFO   Found 4 modules in repository "https://github.com/gruntwork-io/terraform-kubernetes-namespace"

Expected behavior

On second catalog invocation the repositories should not be cloned again (into the same temporary folder).

Either the Medium article is incorrect, I'm doing something wrong, or this is a bug.

Versions