-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 does not read local git config or the GIT_CONFIG env variable #36645
Comments
Hi @arongate, thanks for filing this! Unfortunately, I can't replicate this currently. I noticed in your output that Terraform isn't actually asking for a password the repository in github.com but instead for Thanks! |
Hi @liamcervante , I updated steps to reproduce and put in the correct logs.
|
Thanks for the extra context! Internally, Terraform just calls out to the git client it has available locally for any git related functionality it needs. I think this isn't an issue with Terraform, but something that is not currently possible with git at all. For example, I can't get
With the above, I only set my git configuration using the
This makes sense to me, as all Terraform is doing is calling Can you double check the local configuration works for you even outside of Terraform? Thanks! |
Hi @liamcervante , I checked and you're right. I think this is more related to git client config handling when cloning. Sorry, I'll will close this issue then. Thanks |
Terraform Version
Terraform Configuration Files
Debug Output
outputs
Log file content
TF_LOG_PATH=tf_trace.log
Expected Behavior
Terraform should use the credentials in the local git config file
.git/config
of the project directory.Actual Behavior
Terraform ignores local git config file and keep prompting for username and password to download module from my private repository.
I had the same behaviour using github token or gitlab token with a private repository on gitlab.com.
It works when using global configuration.
Steps to Reproduce
In the terraform code above replace the private repository with any of your private repository and generate a github personal access token with repo permission. Instructions here.
mkdir test
arongate/my-private-repository.git
with your repository slug. eg.<your_username or org>/<your repository name>.git
git init
$HOME/.gitconfig
file or in$PROJECT_DIR/.git/config
fileexport GITHUB_TOKEN=<your_token_here>
git config --local url."https://arongate:${GITHUB_TOKEN}@github.com".insteadOf "https://github.com"
terraform init
Must ask for username. DoIt would works without asking your github credentials.
Additional Context
Terraform commands are run on a shared machine where multiple terraform project are managed by different users (service accounts). Each user uses its own token to download private modules so I can't use the git global configuration.
References
No response
Generative AI / LLM assisted development?
No response
The text was updated successfully, but these errors were encountered: