20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/xssh/aws.rb', line 20
def instance_souces(query='.*', **opts)
instances = ec2.instances
instances.map do |i|
name = i.tags.find{|h| h.key == 'Name' }.value || i.instance_id
next unless name =~ /#{query}/
next unless i.state.name == "running"
addr_type = opts[:address_type] || :public
type = opts[:type] || :linux
{
type: type,
name: name,
host_name: i.send("#{addr_type}_ip_address".to_sym),
instance_id: i.instance_id,
aws: i
}
end
end
|