Skip to content

Instantly share code, notes, and snippets.

@snoremac
Last active December 26, 2015 04:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snoremac/7093308 to your computer and use it in GitHub Desktop.
Save snoremac/7093308 to your computer and use it in GitHub Desktop.
Brief summary of current EC2 spot prices for select instance types. Requires Amazon EC2 API Tools: http://aws.amazon.com/developertools/351
#!/bin/bash -e
INSTANCE_TYPES="m1.small m1.medium m1.large m1.xlarge m2.xlarge m2.2xlarge m2.4xlarge c1.xlarge cc1.4xlarge cc2.8xlarge"
if [ "$#" -gt "0" ]; then
region=$1
else
region=$AWS_REGION
fi
if [ -z $region ]; then
echo "Usage: $0 REGION"
echo "Or, set AWS_REGION environment variable"
exit 1
fi
echo "Pricing for $AWS_REGION region:"
echo ""
for type in $INSTANCE_TYPES; do
price=$(ec2-describe-spot-price-history \
--region $region \
-d Linux/UNIX \
-t $type \
-s $(date +%Y-%m-%dT%H:%M:%S) \
| head -1 \
| awk '{ print $2 }')
echo "$type: $price"
done
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment