hashicorp / hashicorp/terraform
terraform modules source: variable support in source for git username
- Dominant language
- Go
- Stars
- 49.7k
- Forks
- 10.6k
- Avg merge
- 21h 30m
- Merged PRs (30d)
- 100
Description
Hello terraform team, in working on a project I realized there is a feature which might be very useful within modules source, which is to support variable support for git source.
I know this has been discussed in the past already, and that this is not currently supported, I went through the various threads, anyway there was no mention about the use case I'm going to describe which is why I decided to open the feature request anyway.
Let's imagine I have a module in gerrit server, or any other git service on which you need to specify your user account in the source URL.
To use such a module, I will need to do something like:
```
module "my_module" {
source = "git::ssh://myuser@gerrit.server.com:29418/repo.git//modules/mymodule?ref=v1.0.0"
variable = "..."
....
}
```
The need to specify in the source url **myuser** upfront is what is creating issue here, since this is different for each users and cannot be generalized.
As I have no way to override the source URL, it means when I develop the scripts I need to put my username, my colleagues has to change it and put theirs, and if I'm using Jenkins for the automation we ALL need to remember to change it back to the one used from Jenkins before submitting the code.
Ideally I should be able to use override.tf file and specify my own username (or even the entire URL would be ok), so that we do not risk to forget to change it back to the gerrit CI user after working on the code (which is something that happens way TOO often!)
So, at the end, having the possibility to do something like:
```
module "my_module" {
source = "git::ssh://${var.gerrit_user}@gerrit.server:29418/repo.git//modules/mymodule?ref=v1.0.0"
variable = "..."
....
}
```
Or maybe:
```
module "my_module" {
source = "${var.my_module_git_source_url}"
variable = "..."
....
}
```
Is what I'm looking for.
Any other ways to achieve the same objective is perfectly fine, I just need to stop changing it manually since this is way too fragile and prone to human error, _to be honest this exactly what I'm trying to prevent by using IaaC and automation_!
Thank you for your kind consideration & help,
Giordano
Contributor guide
Research direction
The issue names no files, tests, or entry points; start by reviewing Terraform's existing module-source handling and the prior discussion referenced in the thread. Done would be an agreed and tested way to support user or URL customization without manually editing the source for each environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, go, terraform
- Domain
- infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100