Dynamic Module Source (variable for reference)

Did anyone find a solution to this?
We are using CI/CD so worst case i could make this part of a wrapper script but optimally i would be able to change the source URL of my module to something dynamic like:

module "ec2" {
  source = "git::git@gitlab.com:terraform-modules/aws/ec2.git?ref=${var.environment_type}"

Hi @biacz,

The current solution here would be to template the file and generate the configuration you need outside of Terraform based on the situation. From Terraform’s perspective that different source could mean loading an entirely different configuration, so it cannot evaluate the configuration without knowing what that source is.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.