title: terraform templatefile for aws policies list
body: <p>I have an example of this below from my main.tf.
  For some reason it forces double quotes on the template variables to wrap around on my template file while examples from other sources using below without quote wrap:</p>
  <pre><code>%{ for i in split(&quot;,&quot;,mylist) ~}
  Here's a value: ${i}
  %{ endfor }
  </code></pre>
  <p>My syntax shows no error on the file but it will error out when running it
  &quot;%{ for addr in split(&quot;,&quot;,source_vpcs) ~} ${addr} %{ endfor ~}&quot;</p>
  <p>i am getting this error:
  Invalid function
  argument; Invalid value for &quot;str&quot; parameter: string required..</p>
  <p>how can I correctly make use of the list?
  source_vpcs = [&quot;vpc1212&quot;,&quot;vpc21&quot;]</p>
  <pre><code>#i am trying to pass this from the main.tf to pass into aws_vpc_endpoint resource and into its policy attribute.
  
      policy = templatefile(&quot;../templates/access_polices.tmpl&quot;, 
                     {
                       s3env = &quot;dev&quot;
                       account_num = &quot;8888888&quot;
                       source_vpcs = local.source_vpcs
                     }
                 )
  </code></pre>
  <p>here is an the tmpl file
  ####new content###</p>
  <pre><code>${jsonencode(
  {
      &quot;Version&quot;: &quot;2012-10-17&quot;,
      &quot;Statement&quot;: [
          {
              &quot;Sid&quot;: &quot;xx&quot;,
              &quot;Effect&quot;: &quot;Deny&quot;,
              &quot;Action&quot;: [
                  &quot;s3:GetObject&quot;
              ],
              &quot;Resource&quot;: [
                &quot;*&quot;
                ],
              &quot;Condition&quot;: {
              &quot;StringNotEquals&quot;: {
                &quot;aws:SourceVpc&quot;: &quot;${source_vpcs}&quot;,
                &quot;s3:ResourceAccount&quot;: &quot;${account_number}&quot;
                }
          }
          },
          
      ]
  }
  )}
  </code></pre>
  <p>This is my a sample output that I want to achieve</p>
  <pre><code>&quot;Condition&quot;: {
    &quot;StringNotEquals&quot;: {
      &quot;aws:SourceVpc&quot;: 
      [
        &quot;vpc-888888888f&quot;,
        &quot;vpc-999999999f&quot;
  
      ]
      ,
      &quot;s3:ResourceAccount&quot;:
      [
          888888888
       ]
    }
  </code></pre>