Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3647

How-to perform a simple AWS/EC2 rest API call with Curl

$
0
0

Has anyone used cUrl to manage the AWS (EC2) rest API? Here I picked the simplest possible call, listing running instances. Am I missing something or am I clearly showing ignorance of proper cUrl usage? The only real lead I have is this post from 2014 aside from the scattered AWS docs which don't show an actual complete example. (I do realize there are SDKs). It's a curl expert I need...I guess and someone to help me get past the over-use of the word "canonical" by the AWS tech writer.

Rest APIDescribeImages ActionCreate Canonical Request

Bash:

amz_access_key_ID="????"amz_ec2_secret="????"amz_host=ec2.amazonaws.comamz_date8=`date -u "+%Y%m%d"`amz_date_http=`date -uR`amz_date_rfc8601=`date -u "+%Y%m%dT%H%M%SZ"`amz_content_type="application/json"amz_credential="${amz_access_key_ID}/${amz_date8}/us-west-2/ec2/aws4_request"amz_signed_headers="${amz_host};${amz_date_rfc8601};${amz_content_type}"amz_signature=`echo -en ${amz_signed_headers} | openssl sha256 -hmac ${amz_ec2_secret} -binary | base64`params="Action:DescribeInstances;Version:2016-11-15;X-Amz-Algorithm:AWS4-HMAC-SHA256;X-Amz-Credential:${amz_credential};X-Amz-Date:${amz_date_rfc8601};X-Amz-SignedHeaders:${amz_signed_headers};X-Amz-Signature:${amz_signature}"curl -X POST -H "Content-Type:${amz_content_type}" -H "Date:${amz_date_http}" -H "Host:${amz_host}" -F "${params}" http://ec2.amazonaws.com/

Result from Amazon:

<!doctype html><html...HTTP Status 500 – Internal Server Error</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Encountered an Internal Error</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><hr class="line" /></body>

Viewing all articles
Browse latest Browse all 3647

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>