Module: Xssh::Aws

Defined in:
lib/xssh/aws.rb,
lib/xssh/aws/ec2.rb,
lib/xssh/aws/config.rb,
lib/xssh/aws/version.rb

Defined Under Namespace

Classes: Config, EC2

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.configure(&block) ⇒ Object



16
17
18
# File 'lib/xssh/aws.rb', line 16

def configure(&block)
  @config = Config.new(block)
end

.ec2Object



12
13
14
# File 'lib/xssh/aws.rb', line 12

def ec2
  @ec2 ||= EC2.new
end

.instance_souces(query = '.*', **opts) ⇒ Object



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