While there appear to be a few ways to output and filter some AWSCLI commands into this list, does someone have a nice+easy way to list all EC2 instance types for a specific region?
Or perhaps that list is published in a .json file up in a bucket someplace, maintained by AWS?
I'm simply looking for this sort of output:
t1.micro
t2.nano
t2.micro
t2.small
...
Well it seems that at least one programmatic way to do this is to query the AWS Pricing API:
#!/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 '\.'
A gist for this is here, in case of future tweaks: https://gist.github.com/nmagee/b096e6fadf9ac336da7ffdada43f656a
What this is lacking is grouping/specifying by AWS Region, which can be an important distinction -- not every region has all instance type offerings.
As Far As I Know, such list is not available and cannot be queried from aws cli.
Even when running the aws ec2 run-instances, the instance-type parameter lists available instance types and refers to aws docs
Others have parsed the data and made it available.
As others have pointed out, this is not something you can just get out of an AWS API endpoint.
So to fill this gap, I've built a general module for dealing with this issue.
I hope this helps for a variety of use cases: https://gist.github.com/mrsiesta/0e4fac21c0eb0e8977e1de7b5277e63b
来源:https://stackoverflow.com/questions/45283036/list-all-ec2-instance-types-in-a-region-or-az