Last active
December 26, 2015 04:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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