Class: Awry::Rds

Inherits:
Cli
  • Object
show all
Defined in:
lib/awry/rds.rb

Constant Summary collapse

COLORS =
{
  available: :green,
  'in-sync': :green,
}

Instance Method Summary collapse

Instance Method Details

#endpoints(cluster = nil) ⇒ Object



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

def endpoints(cluster = nil)
  client.describe_db_cluster_endpoints(db_cluster_identifier: cluster).map(&:db_cluster_endpoints).flatten.map do |e|
    [ e.db_cluster_identifier, e.endpoint_type, color(e.status), e.endpoint ]
  end.tap do |list|
    print_table list
  end
end

#ls(prefix = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/awry/rds.rb', line 17

def ls(prefix = nil)
  client.describe_db_clusters.map(&:db_clusters).flatten.map do |d|
    cluster = [ d.db_cluster_identifier, d.engine, color(d.status)]
    instances = d.db_cluster_members.map do |i|
      role = i.is_cluster_writer ? 'writer' : 'reader'
      [ '- ' + i.db_instance_identifier, role, color(i.db_cluster_parameter_group_status) ]
    end
    [ cluster ] + instances
  end.flatten(1).tap do |list|
    print_table list
  end
end