class RodeoClown::EC2

Constants

STATUS

Public Class Methods

by_name(name) click to toggle source
# File lib/rodeo_clown/ec2.rb, line 26
def self.by_name(name)
  new instances[name]
end
by_tags(options = {}) click to toggle source

Filter by had of tag values. Keys and values as strings

Examples

RodeoClown::EC2.by_tags("app" => "rodeo", "version" = "2.1")
# => [ instance-1, instanc-2 ]

Returns an array of instances

# File lib/rodeo_clown/ec2.rb, line 38
def self.by_tags(options = {})
  return instances if options.nil? || options.empty?

  instances.tagged_values(options.values).select do |instance|
    tags = instance.tags.to_h
    (options.to_a - tags.to_a).empty?
  end
end
create_instance(options) click to toggle source
# File lib/rodeo_clown/ec2.rb, line 16
def self.create_instance(options)
  new_instance = instances.create(options)
  instances.wait_for_status(:running, 2, [*new_instance])
  new_instance
end
ec2() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 12
def self.ec2
  @ec2 ||= AWS::EC2.new
end
instances() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 8
def self.instances
  ec2.instances
end

Public Instance Methods

create_instance(options) click to toggle source
# File lib/rodeo_clown/ec2.rb, line 22
def create_instance(options)
  self.class.create_instance(options)
end
dns_name() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 67
def dns_name
  ec2.dns_name
end
pending?() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 51
def pending?
  ec2.status == :pending
end
reboot() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 47
def reboot
  ec2.reboot
end
running?() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 55
def running?
  ec2.status == :running
end
stopped?() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 59
def stopped?
  ec2.status == :stopped
end
terminated?() click to toggle source
# File lib/rodeo_clown/ec2.rb, line 63
def terminated?
  ec2.status == :terminated
end