Aws-cli: Can I get a list of instance types from aws cli?

Created on 10 Apr 2015  路  17Comments  路  Source: aws/aws-cli

euca2ools has the euca-describe-instance-types to get a list of the available instance types.

I can't seem to find a corresponding command in aws-cli. Am I missing something?

guidance

Most helpful comment

I'm perplexed. Why is this not a thing? I see requests for this feature dating from 2012.

Trying to get instance types from spot price history has one major drawback I can identify off the top of my head: t2 instances can't be run as spot.

All 17 comments

@StFS I don't believe that this is currently possible through an API call. You can view all of the instance types here, however:

http://aws.amazon.com/ec2/instance-types/

Closing out issue. Daniel is correct, there's no API to list the available instance types so we're not able to expose this via the CLI.

This information is kind of accessible via the AWS Price List API

as well as those two sources, botocore has the list defined in JSON docs. Looking in those is probably the most joined-up way of doing it.

/usr/local/lib/python2.7/dist-packages $ grep -Rl InstanceType botocore/data/ec2
botocore/data/ec2/2014-10-01/service-2.json
botocore/data/ec2/2016-04-01/service-2.json
botocore/data/ec2/2015-03-01/service-2.json
botocore/data/ec2/2014-09-01/service-2.json
botocore/data/ec2/2015-04-15/service-2.json
botocore/data/ec2/2015-10-01/service-2.json
/usr/local/lib/python2.7/dist-packages $

AKA
https://github.com/boto/botocore/blob/develop/botocore/data/ec2/2016-04-01/service-2.json

A more accessible list is available 30% of the way down at:

http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-spot-price-history.html

I'm perplexed. Why is this not a thing? I see requests for this feature dating from 2012.

Trying to get instance types from spot price history has one major drawback I can identify off the top of my head: t2 instances can't be run as spot.

Further to @qfissler 's comment, I found them here:

$ cat /usr/local/lib/python2.7/site-packages/botocore/data/ec2/2016-11-15/service-2.json \
| jq '.shapes.InstanceType.enum'

[
  "t1.micro",
  "t2.nano",
  "t2.micro",
  "...",
  "d2.8xlarge",
  "f1.2xlarge",
  "f1.16xlarge"
]

If is just the list of types what you need, you can play with the aws ec2 describe-spot-price-history help, it have a list of types in it and I suppose it's also updated. But, and that's why I'm here as well, I was looking for something that could help while creating instances with aws, and a list is not exactly helpful since the names are pretty similar to each other, it's easy to remember most of them but what would be really usefull is a list of types with processors, memeory, purpose. I don't think would be sich a hard work to do it since aws, to work, it needs internet. Basically a simple, text page to fetch and elaborate from internet would be more than enough. Eventually, I'm writing a script to fetch https://aws.amazon.com/ec2/instance-types/ and elaborate it with TableExtract but, the day amazon would slightly change that page, I'm off.

To elaborate on @acme's answer, here's an example:

$ aws pricing get-attribute-values --service-code AmazonEC2 --attribute-name instanceType
{
    "AttributeValues": [
        {
            "Value": "c1.medium"
        },
        {
            "Value": "c1.xlarge"
        },
        {
            "Value": "c3.2xlarge"
        },
...
        {
            "Value": "z1d.xlarge"
        },
        {
            "Value": "z1d"
        }
    ]
}

Every region contains values that match AWS's available inventory.

Oh great. thx.

Not every region - presumably a new feature not yet global - but that's hard to believe as this was added in 2015

https://aws.amazon.com/blogs/aws/aws-price-list-api-update-regional-price-lists/

$ aws pricing get-attribute-values --service-code AmazonEC2 --attribute-name instanceType --region eu-west-1

Could not connect to the endpoint URL: "https://api.pricing.eu-west-1.amazonaws.com/"
$

aws pricing help tells you that there are only two endpoints, including us-east-1. So this will work:

aws --region us-east-1 pricing get-attribute-values --service-code AmazonEC2 \
    --attribute-name instanceType

Check out ec2types.io. It helps to get around all EC2 Instance Types. You can also search, filter and compare EC2 instance types based on Region. It helps you choose the right instance type based on configuration and budget

I'm currently working on a cloud management system, and my team and I have been exploring the possibility of extracting all instance types despite the lack of an SDK call from AWS. We've been considering the idea of using sites like ec2types.io to scrape this information via Selenium and storing all instance types and their information in our database. Has anyone looked into this option as a possible solution to dynamically retrieving and storing instance types?

If only sites like that offered an API so we didn't have to scrape the data off UI. This one is open source: https://github.com/powdahound/ec2instances.info, perhaps someone could build a REST wrapper to serve the info over HTTP as JSON for a given query rather than prettified HTML with javascript for interactive manual user queries.

Check out ec2types.io. It helps to get around all EC2 Instance Types. You can also search, filter and compare EC2 instance types based on Region. It helps you choose the right instance type based on configuration and budget

Do you have an API we can query with?

The current version of the AWS CLI offers a new describe-instance-types command for the ec2 service (see also AWS CLI Reference):

$ aws --version
aws-cli/1.16.304 Python/3.7.5 Darwin/19.2.0 botocore/1.13.40
$ aws ec2 describe-instance-types --filters Name=current-generation,Values=true --query 'sort_by(InstanceTypes, &InstanceType)[].InstanceType'
[
    "a1.large",
    "a1.medium",
    "a1.xlarge",
    "c4.4xlarge",
    "c4.8xlarge",
    "c4.large",
    "c5.12xlarge",
    "c5.4xlarge",
    "c5.xlarge",
...
]
Was this page helpful?
0 / 5 - 0 ratings