title: How to escape special characters in Terraform local-exec command line
body: <p>I have the following terraform :</p>
  <pre><code>resource &quot;null_resource&quot; &quot;cognito_user_pool_client_id&quot; {
  
   triggers  =  { always_run = &quot;${timestamp()}&quot; }
   provisioner &quot;local-exec&quot; {
    command = &quot;aws cognito-idp list-user-pool-clients --user-pool-id  ${aws_cognito_user_pool.main.id} --region ${var.region} | grep -o '&quot;ClientId&quot;: &quot;[^&quot;]*' | grep -o '[^&quot;]*$' &gt; ${path.module}/cognito_app_client.txt&quot;
  
    depends_on = [&quot;aws_cognito_user_pool_domain.main&quot;]
  }
  </code></pre>
  <p>where I am trying to get the app client id from userpool in cognito. Anyway this line fails with terraform :</p>
  <pre><code>Error: Invalid character
  
    on kibana_cognito.tf line 163, in resource &quot;null_resource&quot; &quot;cognito_user_pool_client_id&quot;:
   163:   command = &quot;aws cognito-idp list-user-pool-clients --user-pool-id  ${aws_cognito_user_pool.main.id} --region ${var.region} | grep -o '&quot;ClientId&quot;: &quot;[^&quot;]*' | grep -o '[^&quot;]*$' &gt; ${path.module}/cognito_app_client.txt&quot;
  
  This character is not used within the language.
  
  
  Error: Invalid character
  
    on kibana_cognito.tf line 163, in resource &quot;null_resource&quot; &quot;cognito_user_pool_client_id&quot;:
   163:   command = &quot;aws cognito-idp list-user-pool-clients --user-pool-id  ${aws_cognito_user_pool.main.id} --region ${var.region} | grep -o '&quot;ClientId&quot;: &quot;[^&quot;]*' | grep -o '[^&quot;]*$' &gt; ${path.module}/cognito_app_client.txt&quot;
  
  Single quotes are not valid. Use double quotes (&quot;) to enclose strings.
  
  
  Error: Invalid character
  
    on kibana_cognito.tf line 163, in resource &quot;null_resource&quot; &quot;cognito_user_pool_client_id&quot;:
   163:   command = &quot;aws cognito-idp list-user-pool-clients --user-pool-id  ${aws_cognito_user_pool.main.id} --region ${var.region} | grep -o '&quot;ClientId&quot;: &quot;[^&quot;]*' | grep -o '[^&quot;]*$' &gt; ${path.module}/cognito_app_client.txt&quot;
  
  This character is not used within the language.
  </code></pre>
  <p>This works in aws cli :</p>
  <pre><code>(venv) ➜  virginia git:(master) ✗ aws cognito-idp list-user-pool-clients --user-pool-id  123456 --region us-east-1 | grep -o '&quot;ClientId&quot;: &quot;[^&quot;]*' | grep -o '[^&quot;]*$'
  dsewe24dwr2e
  </code></pre>
  <p>how to make this work in terraform ?</p>