title: how to pass a list of double quoted strings as an azure pipeline variable input to terraform task?
body: <p>I am trying to pass a list of strings as an azure pipeline variable to a terraform task.</p>
  <p>I have a variable created for the pipeline called such that <code>ips = [\&quot;1.1.1.1\&quot;, \&quot;2.2.2.2\&quot;]</code> and I can access this in the azure pipeline using <code>$(ips)</code></p>
  <p>I want to pass this variable as mentioned <a href="https://www.terraform.io/docs/configuration/variables.html#variables-on-the-command-line" rel="nofollow noreferrer">here</a> in the official terraform documentation:
  <code>terraform apply -var='image_id_list=[&quot;ami-abc123&quot;,&quot;ami-def456&quot;]'</code> to the terraform plan task</p>
  <p>here is my terraform plan section of the yaml:</p>
  <pre><code>        - task: TerraformTaskV1@0
            inputs:
              provider: 'azurerm'
              command: 'plan'
              commandOptions: '--var-file variables/$(Build.SourceBranchName)/$(Build.SourceBranchName).tfvars  -var=''allowips=$(ips)''' 
              environmentServiceNameAzureRM: $(linked_service)
            displayName: 'Terraform plan'
  </code></pre>
  <p>when the pipeline runs, it fails at the terraform plan step with the error -</p>
  <pre><code>terraform plan --var-file variables/dev/dev.tfvars -var='allowips=[ \1.1.1.1&quot;, &quot;2.2.2.2&quot; ]'
  stat \1.1.1.1&quot;, &quot;2.2.2.2&quot; ]': no such file or directory
  ##[error]Error: The process '/opt/hostedtoolcache/terraform/0.12.28/x64/terraform' failed with exit code 1
  </code></pre>
  <p>I have also tried various combinations of for declaring the azure pipeline variable like:
  <code>ips = [&quot;\&quot;1.1.1.1\&quot;, \&quot;2.2.2.2&quot;\]</code></p>
  <p>which also gives the same error -</p>
  <pre><code>terraform plan --var-file variables/dev/dev.tfvars -var='allowips=[ &quot;1.1.1.1&quot;, &quot;2.2.2.2&quot; ]'
  stat &quot;1.1.1.1&quot;, &quot;2.2.2.2&quot; ]': no such file or directory
  ##[error]Error: The process '/opt/hostedtoolcache/terraform/0.12.28/x64/terraform' failed with exit code 1
  
  </code></pre>
  <p>I have tried to a lot of combinations of setting quotes or double quotes on the <code>commandOptions</code> value and also the <code>ips</code> variable but I am getting the same errors (or valid terraforms error).</p>
  <p>It seems the first double quote in the azure variable seems to causing some issues. Any pointers o how to pass a list of double quoted strings as an azure pipeline variable input to terraform task is much appreciated. Thanks!</p>
  <p>edit -</p>
  <p>I hardcoded the values directly in the yaml but still getting errors.</p>
  <pre><code>commandOptions: '--var-file variables/$(Build.SourceBranchName)/$(Build.SourceBranchName).tfvars -var=''allowips=[\&quot;1.1.1.1\&quot;, \&quot;2.2.2.2\&quot;]'''
  </code></pre>
  <p>and it basically does not accept the ip values and asks for a manual entry:</p>
  <pre><code>/opt/hostedtoolcache/terraform/0.12.28/x64/terraform plan --var-file variables/dev/dev.tfvars -var='allowips=[\1.1.1.1&quot;, &quot;2.2.2.2&quot;]'
  var.allowips
    Enter a value: 
  </code></pre>
  <p>again it seems there is a problem around the first double quote.</p>