title: How do you add spaces for aws cloudformation deploy --parameter-overrides and/or --tags?
body: <p>I am trying to get spaces into the tags parameter for the aws cli and it works if I hardcode it but not if I use bash variables. What is going on and how do I fix it?</p>
  
  <p><strong>This works with out spaces:</strong></p>
  
  <pre><code>aws cloudformation deploy  \
        --template-file /path_to_template/template.json \ 
        --stack-name my-new-stack \
        --tags Key1=Value1 Key2=Value2
  </code></pre>
  
  <p><strong>This works with out spaces but with variables:</strong></p>
  
  <pre><code>tags="Key1=Value1 Key2=Value2" 
  aws cloudformation deploy \
    --template-file /path_to_template/template.json \ 
    --stack-name my-new-stack \
    --tags $tags
  </code></pre>
  
  <p><strong>This works with spaces:</strong></p>
  
  <pre><code>aws cloudformation deploy  \
    --template-file /path_to_template/template.json \ 
    --stack-name my-new-stack \
    --tags 'Key1=Value1' 'Key Two=Value2'
  </code></pre>
  
  <p><strong>This does not work, spaces and variables:</strong></p>
  
  <pre><code>tags="'Key1=Value1' 'Key Two=Value2'"
  
  aws cloudformation deploy  \
    --template-file /path_to_template/template.json \ 
    --stack-name my-new-stack \
    --tags $tags
  </code></pre>
  
  <p><strong>Attempting to fix bash expansion, also does not work, spaces and variables:</strong></p>
  
  <pre><code>tags="'Key1=Value1' 'Key Two=Value2'"
  
  aws cloudformation deploy  \
    --template-file /path_to_template/template.json \ 
    --stack-name my-new-stack \
    --tags "$tags"
  </code></pre>
  
  <p><strong>Attempting to fix bash expansion, also does not work, spaces and variables:</strong></p>
  
  <pre><code>tags="'Key1=Value1' 'Key Two=Value2'"
  
  aws cloudformation deploy  \
    --template-file /path_to_template/template.json \ 
    --stack-name my-new-stack \
    --tags "$(printf '%q' $tags)"
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Invalid parameter: Tags Reason: The given tag(s) contain invalid
    characters (Service: AmazonSNS; Status Code: 400; Error Code:
    InvalidParameter; Request ID</p>
  </blockquote>