Forked from nmagee/retrieve-ec2-instance-types.sh
Last active
November 13, 2019 10:50
-
-
Save ahgittin/1dee8b9f322252405879e1cf6d271932 to your computer and use it in GitHub Desktop.
Query the AWS Pricing API to get all currently available EC2 instance types
This file contains hidden or 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
curl https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json > ec2-pricing.json | |
cat ec2-pricing.json | jq -r '.products[].attributes["instanceType"]' | sort -u | grep '\.' > instances | |
cat ec2-pricing.json | jq -c '[.products[].attributes] | [ .[] | select(.instanceType) | select(.location) | {location,instanceType} ] | group_by(.location) | [{ (.[][0].location): [ .[][].instanceType ] | unique }] | sort' > instance-by-region.json | |
cat instance-by-region.json | jq -r '[ .[] | to_entries | { (.[].key): .[].value | join(", ") } ] > instances-string-by-region.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
generates the following (note the list of instance types is the same for each, even though I think some instance types aren't actually available in some regions, even though there's a pricing code):