Skip to content

Instantly share code, notes, and snippets.

@ilyash
Last active February 20, 2023 11:54
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyash/4573706 to your computer and use it in GitHub Desktop.
Save ilyash/4573706 to your computer and use it in GitHub Desktop.
Quick hack to create CSV containing AWS EC2 instance types with their properties. This format is more convenient (at least for me) than the types page.
#!/usr/bin/python
'''
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
# By Ilya Sher, Coding-Knight LTD.
# Quick hack to create CSV containing AWS EC2 instance types
# with their properties. This format is more convenient (at least for me)
# than the types page.
# 1. No warranties whatsoever!
# 2. Note that "micro" is "up to 2" EC2 Compute units, not "2"
# Prerequisites:
# * save http://aws.amazon.com/ec2/instance-types/
# as 'Downloads/Amazon EC2 Instance Types.html'
import os, re
REGEXES = (
'<p style="padding-left:2em;"><strong>(.*) Instance',
'>(.*?) .iB.*memory',
'(\d+) EC2 Compute Unit',
'(.*) storage',
'I/O Performance: (.*?)<',
'EBS-Optimized Available: (.*?)<',
'API name: (.*?)<',
)
REGEXES_N = len(REGEXES)
FNAME = os.path.join(
os.getenv('HOME'),
'Downloads/Amazon EC2 Instance Types.html'
)
regex_ptr = 0
print "Name , Memory , EC2 Compute units , Storage , I/O performance , EBS-Optimized Available , API name"
for line in open(FNAME):
m = re.search(REGEXES[regex_ptr], line)
if m:
print m.group(1).replace(',', ''),
regex_ptr = regex_ptr + 1
if regex_ptr == REGEXES_N:
regex_ptr = 0
print
else:
print ",",
Name Memory EC2 Compute units Storage I/O performance EBS-Optimized Available API name
M1 Small 1.7 GiB 1 160 GB instance Moderate No m1.small
M1 Medium 3.75 GiB 2 410 GB instance Moderate No m1.medium
M1 Large 7.5 GiB 4 850 GB instance High 500 Mbps m1.large
M1 Extra Large 15 GiB 8 1690 GB instance High 1000 Mbps m1.xlarge
M3 Extra Large 15 GiB 13 EBS Moderate No m3.xlarge
M3 Double Extra Large 30 GiB 26 EBS High No m3.2xlarge
Micro 613 MiB 2 EBS Low No t1.micro
High-Memory Extra Large 17.1 GiB 5 420 GB of instance Moderate No m2.xlarge
High-Memory Double Extra Large 34.2 GiB 13 850 GB of instance High No m2.2xlarge
High-Memory Quadruple Extra Large 68.4 GiB 26 1690 GB of instance High 1000 Mbps m2.4xlarge
High-CPU Medium 1.7 GiB 5 350 GB of instance Moderate No c1.medium
High-CPU Extra Large 7 GiB 20 1690 GB of instance High No c1.xlarge
Cluster Compute Eight Extra Large 60.5 GiB 88 3370 GB of instance Very High (10 Gigabit Ethernet) No* cc2.8xlarge
Cluster GPU Quadruple Extra Large 22 GiB 5 1690 GB of instance Very High (10 Gigabit Ethernet) No* cg1.4xlarge
High I/O Quadruple Extra Large 60.5 GiB 35 2 SSD-based volumes each with 1024 GB of instance Very High (10 Gigabit Ethernet) No*** hi1.4xlarge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment