Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Query the AWS Pricing API to get all currently available EC2 instance types
#!/bin/bash
curl https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json | jq -r '.products[].attributes["instanceType"]' | sort -u | grep '\.'
@PatMyron
Copy link

PatMyron commented Aug 8, 2019

@TeunRoefs not safe to assume. Some regions may not have some instance types. But this can be run on the region-specific files:

curl -s https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/$REGION/index.json | jq -r '.products[].attributes["instanceType"]' | sort -u | grep '\.'

Instance types in every region:

for REGION in $(aws ec2 describe-regions --query "Regions[*].RegionName" --output text)
do
  echo $REGION
  curl -s https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/$REGION/index.json | jq -r '.products[].attributes["instanceType"]' | sort -u | grep '\.'
done

Instance families in every region:

for REGION in $(aws ec2 describe-regions --query "Regions[*].RegionName" --output text)
do
  echo $REGION
  curl -s https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/$REGION/index.json | jq -r '.products[].attributes["instanceType"]' | sort -u | grep '\.' | sed 's/\..*//' | sort -u
done
eu-north-1
c5
c5d
d2
i3
m5
m5d
r5
r5d
t3
ap-south-1
c4
c5
c5d
c5n
d2
i2
i3
m4
m5
m5d
p2
r3
r4
r5
r5d
t2
t3
x1
eu-west-3
c4
c5
c5d
d2
i3
m4
m5
m5a
m5d
r4
r5
r5a
r5d
t2
t3
t3a
x1
eu-west-2
c4
c5
c5d
d2
g3
g3s
i3
m4
m5
m5d
p3
r4
r5
r5d
t2
t3
t3a
x1
z1d
eu-west-1
a1
c1
c3
c4
c5
c5d
c5n
cc2
cr1
d2
f1
g2
g3
g3s
h1
hs1
i2
i3
i3en
m1
m2
m3
m4
m5
m5a
m5d
p2
p3
p3dn
r3
r4
r5
r5a
r5d
t1
t2
t3
t3a
x1
x1e
z1d
ap-northeast-3
c3
c4
c5
c5d
d2
i3
m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r5d
t2
t3
t3a
x1
x1e
us-west-1
c1
c3
c4
c5
c5d
d2
f1
g2
g3
g3s
i2
i3
i3en
m1
m2
m3
m4
m5
m5a
m5d
r3
r4
r5
r5a
r5d
t1
t2
t3
t3a
z1d
us-west-2
a1
c1
c3
c4
c5
c5d
c5n
cc2
cr1
d2
f1
g2
g3
g3s
h1
hs1
i2
i3
i3en
m1
m2
m3
m4
m5
m5a
m5ad
m5d
p2
p3
p3dn
r3
r4
r5
r5a
r5ad
r5d
t1
t2
t3
t3a
x1
x1e
z1d
ap-east-1
c5
c5d
d2
i3
m5
m5d
r5
r5d
t3
x1
me-south-1
c5
c5d
d2
i3
m5
m5d
r5
r5d
t3
us-gov-east-1
c5
c5d
c5n
i3
m5
m5a
m5d
r5
r5a
r5d
t3
t3a
x1
x1e
us-gov-west-1
c1
c3
c4
c5
c5d
c5n
cc2
d2
f1
g3
hs1
i2
i3
m1
m2
m3
m4
m5
m5a
m5ad
m5d
p2
p3
r3
r4
r5
r5a
r5ad
r5d
t1
t2
t3
t3a
x1
x1e
cn-north-1
c3
c4
c5
c5d
d2
g2
g3
g3s
i2
i3
m1
m3
m4
m5
m5a
m5d
p2
p3
r3
r4
r5
r5a
r5d
t2
t3
t3a
x1
cn-northwest-1
c4
c5
c5d
d2
i2
i3
m4
m5
m5a
m5d
p3
r4
r5
r5a
r5d
t2
t3
t3a
x1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment