Class: Awful::Rds

Inherits:
Cli show all
Defined in:
lib/awful/rds.rb

Instance Method Summary collapse

Methods inherited from Cli

#initialize

Constructor Details

This class inherits a constructor from Awful::Cli

Instance Method Details

#dns(name) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/awful/rds.rb', line 32

def dns(name)
  rds.describe_db_instances.map(&:db_instances).flatten.find do |db|
    db.db_instance_identifier == name
  end.tap do |db|
    puts "#{db.endpoint.address}:#{db.endpoint.port}"
  end
end

#dump(name) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/awful/rds.rb', line 23

def dump(name)
  rds.describe_db_instances.map(&:db_instances).flatten.find do |db|
    db.db_instance_identifier == name
  end.tap do |db|
    puts YAML.dump(stringify_keys(db.to_hash))
  end
end

#ls(name = /./) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/awful/rds.rb', line 7

def ls(name = /./)
  fields = options[:long] ?
    ->(d) { [d.db_instance_identifier, d.availability_zone, d.db_instance_class, d.db_instance_status, d.preferred_maintenance_window, d.storage_type, d.allocated_storage,
             d.engine, d.engine_version] } :
    ->(d) { [d.db_instance_identifier] }

  rds.describe_db_instances.map(&:db_instances).flatten.select do |db|
    db.db_instance_identifier.match(name)
  end.map do |db|
    fields.call(db)
  end.tap do |list|
    print_table list
  end
end