title: How to invoke RunInstances action on ec2.amazonaws.com using shell script?
body: <p>Every time I am getting the error:</p>
  
  <blockquote>
    <p>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</p>
  </blockquote>
  
  <p>This is my script:</p>
  
  <pre><code>#!/bin/bash
  
  dt=$(date +%FT%TZ | sed 's/:/%3A/g')
  echo "$dt"
  
  q="GET
  elasticmapreduce.amazonaws.com
  /
  AWSAccessKeyId=652387uyt56182&amp;Action=DescribeJobFlows&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=$dt&amp;Version=2009-03-31"
   sig=$(echo -n "$q" | openssl dgst -sha256 -hmac q65272/ui5878/t62989231232 - binary| openssl enc -base64)
  
  echo "the signature without url encoding is $sig"
  
  
  curl --get --url  "https://ec2.amazonaws.com/?Action=StartInstances&amp;AWSAccessKeyId=ty76476587yt4756&amp;InstanceId.1=t-76wergf&amp;MaxCount=1&amp;MinCount=1&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=$dt&amp;Signature=$sig&amp;Version=2012-07-20"
  </code></pre>
  
  <p>Can anyone tell me what is wrong in the code? I have altered my secret credentials for confidentiality.
  Thanks.</p>