title: Terraform plan garbles jq/json output, but terraform console doesn't
body: <p>I've been building a github automation with TF to build an S3 bucket with one or more IAM roles as principals. When I assign the roles as JSON to a var (jsonencode/formatlist), testing with terraform console displays the resulting policy perfectly.</p>
  <p>But when I run a TF plan the json is garbled instead, resulting in a badly formed principal block.</p>
  <p>Here's my variable block with AWS account numbers</p>
  <pre><code>variable &quot;account_num&quot; {
    default = [
    &quot;123456789011&quot;,
    &quot;123456789012&quot;
    ]
  }
  </code></pre>
  <p>Terraform code block looks like this.</p>
  <pre><code>&quot;Principal&quot;: {
      &quot;AWS&quot;: ${jsonencode(formatlist(&quot;arn:aws:iam::%s:role/role-access&quot;, var.account_num))}
  },
  </code></pre>
  <p>When I use the terraform console to try this var block with jsonencode/formatlist, it creates the policy block perfectly.</p>
  <pre><code>$ terraform console    
  &gt; jsonencode(formatlist(&quot;arn:aws:iam::%s:role/role-access&quot;, var.account_num))
        [&quot;arn:aws:iam::123456789011:role/role-access&quot;,&quot;arn:aws:iam::123456789012:role/role-access&quot;]
  </code></pre>
  <p>However in the actual terraform plan, the block is garbled.</p>
  <pre><code>+ Principal = {
      + AWS = [
          + &lt;&lt;~EOT
                arn:aws:iam::[
                  &quot;123456789011&quot;,
                  &quot;123456789012&quot;
                ]:role/role-access
            EOT,
        ]
    }
  </code></pre>
  <p>Thanks for any help!</p>