-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathec2-instance-types.rb
More file actions
33 lines (28 loc) · 853 Bytes
/
ec2-instance-types.rb
File metadata and controls
33 lines (28 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require './config'
require 'aws-sdk-ec2'
require 'yaml'
def main
initialize_client
get_instance_types
end
def initialize_client
@ec2 = Aws::EC2::Client.new(region: @region)
end
def get_instance_types
filters = [{ name: 'current-generation', values: ['true']},
{ name: 'hypervisor', values: ['nitro']}]
parsed = []
result = @ec2.describe_instance_types(filters: filters).each do |response|
response.instance_types.each do
parsed << {
instance_type: _1.instance_type,
arch: _1.processor_info.supported_architectures.first,
ram_gb: (_1.memory_info.size_in_mi_b / 1024.0).round,
vcpus: _1.v_cpu_info.default_v_cpus
}
end
end
parsed.sort_by! { [_1[:arch], _1[:instance_type].gsub(/\..*$/, ''), _1[:ram_gb]] }
File.write('instance_types.yml', YAML.dump(parsed))
end
main