Parameterizing module source

I know you can’t parameterize module source but I still need a solution to the following problem.

I’m having a git repo with several modules and examples. There are 2 main branches -

  1. main
  2. dev

The developers need the examples to use their local copy of the modules, while the main branch need to use the modules from terraform registry.

Here is what an example should look like for main branch:

module "asset" {
  source  = "company/module"
}

And this is how it should look like for developers:

module "asset" {
  source  = "../modules/module"
}

We regularly merge code from dev branch to main. Does anyone have a possible solution for this problem?
Thanks

The most practical solution to this problem is to abandon using modules from a registry and keep them in the Git repo for both main and dev branches.

1 Like

By you say “keep them in the Git repo”, do you mean using local_source?

I don’t recognize what local_source means, but yes, in the way described at the destination of that link.

1 Like