class Ctrl::Commands::ListInstances

Public Instance Methods

filters() click to toggle source
# File lib/ctrl/commands/list_instances.rb, line 8
def filters
  @filters ||= [
    { name: 'tag:Environment', values: [env_name].compact },
    { name: 'tag:Name', values: [instance_name].compact },
    { name: 'instance-state-name', values: [instance_state].compact }
  ].delete_if {|e| e[:values].empty?}
end
instances() click to toggle source
# File lib/ctrl/commands/list_instances.rb, line 20
def instances
  @instances ||= scope.inject([]) do |a, e|
    a << Ctrl::Ec2Instance.from_instance(e)
  end
end
perform() click to toggle source
# File lib/ctrl/commands/list_instances.rb, line 26
def perform
  puts "Instances"
  puts instances.map(&:to_s)
end
scope() click to toggle source
# File lib/ctrl/commands/list_instances.rb, line 16
def scope
  filters.any? ? client.instances(filters: filters) : client.instances
end