title: How to add remote azure repo for terraform modules to make terraform code work on Azure pipelines
body: <p>Source definition given below works for terraform modules BUT it has a PAT TOKEN. Works fine on local VM as well as on Azure Pipelines. This question is about how to define source definition for terraform modules but without hard coding PAT TOKEN</p>
  
  <p>Working copy of code:</p>
  
  <pre><code>source = "git::https://&lt;PAT TOKEN&gt;@&lt;AZURE DEVOPS URL&gt;/DefaultCollection/&lt;Project Name&gt;y/_git/terraform-modules//&lt;sub directory&gt;"
  </code></pre>
  
  <p>I tried the below:</p>
  
  <pre><code>    git::https://&lt;AZURE DEVOPS URL&gt;/DefaultCollection/&lt;Project Name&gt;/_git/terraform-modules.git//&lt;sub directory&gt;
  </code></pre>
  
  <p>That gave me error like below:</p>
  
  <pre><code>"git::https://&lt;AZURE DEVOPS URL&gt;/DefaultCollection/&lt;Project Name&gt;/_git/terraform-modules":
  error downloading
  'https://&lt;AZURE DEVOPS URL&gt;/DefaultCollection/&lt;Project Name&gt;/_git/terraform-modules':
  /usr/bin/git exited with 128: Cloning into
  '.terraform/modules/resource_group'...
  fatal: could not read Username for 'https://&lt;AZURE DEVOPS URL&gt;':
  terminal prompts disabled
  </code></pre>
  
  <p>Added my user name without the domain part like below:</p>
  
  <pre><code>source                  = "git::https://&lt;USERNAMEM@&lt;AZURE DEVOPS URL&gt;/DefaultCollection/&lt;PROJECT NAME&gt;/_git/terraform-modules.git//compute"
  </code></pre>
  
  <p>Error below:</p>
  
  <pre><code>"git::https://&lt;USERNAME&gt;@&lt;AZURE DEVOPS&gt;/DefaultCollection/&lt;PROJECT&gt;/_git/terraform-modules.git":
  error downloading
  'https://&lt;USERNAME&gt;@&lt;AZURE DEVOPS&gt;/DefaultCollection/&lt;PROJECT&gt;/_git/terraform-modules.git':
  /usr/bin/git exited with 128: Cloning into '.terraform/modules/sql_vms'...
  fatal: could not read Password for
  'https://&lt;USERNAME&gt;@&lt;AZURE DEVOPS&gt;': terminal prompts disabled
  </code></pre>
  
  <p>When Build pipeline can do checkout even without specifying username and password why do we have to mention in terraform code.</p>
  
  <p>Azure Pipeline Agent has git credentials. Not sure if this is going to work at all without PAT Token?</p>