Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform Modules pulled from git sources should allow ref to be specified by variable #26888

Closed
ryanfelder opened this issue Nov 11, 2020 · 2 comments
Labels
enhancement new new issue not yet triaged

Comments

@ryanfelder
Copy link

ryanfelder commented Nov 11, 2020

I am a Terraform Enterprise user implementing a new project.
We have full separate deployments for each SDLC tier (dev, qa, prod, etc).
I would like to be able to promote terraform code using the same branching workflow that I use for code.

This means I am deploying development branch terraform code from the develop branch, and I am deploying production terraform code from the master branch.

I presently have to hard-code my branch into every file where I am pulling terraform modules from git.. for example

module "metrics" {  
  source                   = "git::ssh://[email protected]/group/infrastructure/terraform/modules/metrics.git?ref=develop"  
}  

This, however, complicates the merge process. I would prefer to be able to pass this in as a variable.
I have seen the many tickets here about using variables in source declarations, and why that is a bad idea.
I am not suggesting to use a variable in the source url itself, but perhaps as a different parameter.. for example

module "metrics" {  
  source                   = "git::ssh://[email protected]/group/infrastructure/terraform/modules/metrics.git"  
  ref                      = var.branch  
}  

This would allow me to deploy the exact same code in multiple workspaces/organizations, differing only in what value I have set for the branch variable. I would then set the branch variable to 'develop' for my dev infrastructure, 'master' for my prod infrastructure, and so on.

@ryanfelder ryanfelder added enhancement new new issue not yet triaged labels Nov 11, 2020
@pkolyvas
Copy link
Contributor

I'm going to close this as a duplicate / family member of #25587

We don't have any plans to tackle module source interpolation at the moment unfortunately and the ref here is part of the source for better or worse, even if it is a separate argument. This value has to be known during initialization.

That said, thanks for sharing your use case so clearly. Even though the issue will be closed it will be helpful when we do finally tackle this area of Terraform.

@ghost
Copy link

ghost commented Dec 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants