Skip to content

Instantly share code, notes, and snippets.

@KentaroAOKI
Created September 7, 2011 10:09
Show Gist options
  • Save KentaroAOKI/1200207 to your computer and use it in GitHub Desktop.
Save KentaroAOKI/1200207 to your computer and use it in GitHub Desktop.
A script to use https://gist.github.com/1200104 to query the All AWS usage reports programmatically.
#!/bin/sh
AWSUSAGE=aws_usage.py
TEMPFILE=/tmp/aws_all_prev_usage$$.xml
USERID=$1
PASSWORD=$2
if [ "" = "$USERID" ]
then
exit
fi
if [ "" = "$PASSWORD" ]
then
exit
fi
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $TEMPFILE
echo "<ServiceUsage>" >> $TEMPFILE
for SERVICE in `$AWSUSAGE -l`
do
$AWSUSAGE -s $SERVICE -f xml -U "$USERID" -P "$PASSWORD" -t aws-portal-prev-bill-period | grep -v "^<" >> $TEMPFILE
done
echo "</ServiceUsage>" >> $TEMPFILE
cat $TEMPFILE
rm $TEMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment