Is there an API to get a list of available instance types on EC2?
I can see that there is a price list JSON file that you can download but it\'s 70 megabytes which is no
This information is available as part of the EC2 API. The API defines various resource shapes which can be exposed by language-specific SDKs. For example, the Python library botocore (which also powers the AWS CLI) exposes instance types via the EC2 service model:
import botocore.session
sess = botocore.session.Session()
available_types = sess.get_service_model('ec2').shape_for('InstanceType').enum
If you're working with EC2 from Python, there's a good chance you're working with the higher level boto3 library. A boto3 EC2 client will already have a reference to the underlying botocore service mode, so you can do this instead:
client = boto3.client('ec2')
client._service_model.shape_for('InstanceType').enum
SDKs for other languages should also expose the InstanceType
resource shape. Since this comes directly from the API and tends to be automatically pushed to the SDK repos, the data should be common as long as you're using the same API version (compare the JSON API definition in botocore and the JavaScript SDK, for instance).
There is no API to retrieve a list of Amazon EC2 instance types.
You could use some 3rd-party sites: