-
-
Save abcarroll/86850dc3cb4d449719888ba6a213b051 to your computer and use it in GitHub Desktop.
Bash-friendly ec2 prices
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
#!/usr/bin/env bash | |
URL="http://a0.awsstatic.com/pricing/1/ec2/ri-v2/linux-unix-shared.min.js" | |
echo -e "1S- = Std 1 Year Term \t3S- = Std 3 Year Term\t3C- = Convertibe 3 Year Term" | |
echo -e " -NON = No Up Front Cost\t -PRT = Partially Upfront\t -ALL = Entire Term Upfront" | |
echo "" | |
echo -e "Instance\tONDMND\t1S-NON\t1S-PRT\t1S-ALL\t3S-PRT\t3S-ALL\t3C-NON\t3C-PRT\t3C-ALL\n" | |
(echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s "$URL" ) |\ | |
node |\ | |
jq -r '.config.regions[] | | |
select(.region == "us-east-1") | | |
.instanceTypes[] | | |
[ | |
.type, | |
( .terms[] | select(.term == "yrTerm1Standard") | .onDemandHourly[].prices.USD), | |
( | |
.terms[] | select(.term == "yrTerm1Standard") | .purchaseOptions | | |
map(.valueColumns[] | select(.name == "effectiveHourly") | .prices.USD)[] | |
), | |
( | |
.terms[] | select(.term == "yrTerm3Standard") | .purchaseOptions | | |
map(.valueColumns[] | select(.name == "effectiveHourly") | .prices.USD)[] | |
), | |
( | |
.terms[] | select(.term == "yrTerm3Convertible") | .purchaseOptions | | |
map(.valueColumns[] | select(.name == "effectiveHourly") | .prices.USD)[] | |
) | |
] | join("\t")' | sed 's/t2\.nano/t2\.nano-/g'; |
This is really nice. Thank you for this!
Just as an FYI - if anyone is looking at this, the file: http://a0.awsstatic.com/pricing/1/ec2/ri-v2/linux-unix-shared.min.js used by this script is no longer being updated by AWS, so this awesome script doesn't really cut the mustard anymore, unfortunately...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for writing this. Saved in my toolbox. You rock!