Instance types: (t2.micro, t2.small, c4.large...) those listed here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
I want to access a list of these through boto3. something like:
conn.get_all_instance_types()
or even
conn.describe_instance_types()['InstanceTypes'][0]['Name']
which everything seems to look like in this weird api.
I've looked through the docs for client and ServiceResource, but i can't find anything that seems to come close. I haven't even found a hacky solution that lists something else that happen to represent all the instance types.
Anyone with more experience of boto3?
Try this
The EC2 API does not provide a way to get a list of all EC2 instance types. I wish it did. Some people have cobbled together their own lists of valid types by scraping sites like this but for now that is the only way.
I need it too, however, there are no suitable codes for this purpose. I modify one by myself. Enjoy! May someone need it also.
Following code is modified from libcloud/contrib/scrape-ec2-prices.py And this program will generate a dict about available instance types
This information can be retrieved in the JSON provided by the recently-announced AWS Price List API. As a simple example using the Python
requests
module:Note that this might take a while... as of today, the current EC2 Offers JSON file ( https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json ) is 173MB, so it takes a while both to retrieve and to parse. The current result is 99 distinct instance types.