Is it possible to reference the same Git repository as source in multiple modules?

Hi,
I have following situation:

  1. We use 1 Git repository (github.com:git_org/modules_repo.git) as a source of all Terraform infrastructure, locally-developed and downloaded Terraform modules.
  2. These modules are in repository’s subfolder.
  3. Several modules are used within single .tf file. All modules refer to the same repository’s address and version as source.

Example:

module "kops_data_iam" {
  source       = "git@github.com:git_org/modules_repo.git//components/terraform/.modules/kops-data-iam?ref=main"
  cluster_name = var.cluster_name
}

module "kops_data_network" {
  source       = "git@github.com:git_org/modules_repo.git//components/terraform/.modules/kops-data-network?ref=main"
  cluster_name = var.cluster_name
}

we’re getting error message:

Initializing modules…
Downloading git::GitHub - cloudposse/terraform-aws-kms-key at tags/0.4.0 for kms_key…

Error: Failed to download module
Could not download module “kops_data_network” (kops-data.tf:15) source code
from “git@github.com:git_org/modules_repo.git?ref=main”: subdir
“components/terraform/.modules/kops-data-network” not found

I’ve tried:

  1. Using different source formats described in Module Sources - Terraform by HashiCorp - for Github, generic Git, git via ssh & https etc.
  2. Removing cached .terraform files, running terraform init and downloading all modules again.
  3. Replaced ‘source’ for kops_data_iam with local path - “…/modules/kops-data-iam”. After that it was able to download kops_data_network successfully.
    After “3” I replaced kops_data_iam back with reference to remote Git repository and it stopped working again. Error message was the same. It looks like using the same Git repository as source for different modules is not supported.

Could someone confirm it’s expected behavior and whether it’s supported scenario, please?