I am currently using an Azure DevOps pipeline to trigger a terraform plan
against an existing infrastructure.
Within this pipeline during the terraform init
stage, terraform will analyze the scripts and download modules from an external repository. During the initial stage of running this pipeline we encountered the following error.
fatal: could not read Username for 'https://github.com': terminal prompts disabled
which we temporarily resolved using PAT
git config --global url."https://$(GITHUB-USER-ACCT):$(GITHUB-PERSONAL-ACCESS-TOKEN)@github.com".insteadOf https://github.com
However as this adds the additional load of maintaining a PAT, I was wondering whether we can move from this method to an method of using the GitHub Service connection (Which is automatically created when creating the pipeline) to be used as an authentication mechanism. This Service connection was created using the OAuth application. The Service connection that we used has read permissions on the centralized repository which contains the Terraform modules.
The following link describes how to do this for a Azure Hosted repository. Is there any way to accomplish this for a Repo hosted in GitHub.