class AwsAuditor::RDSInstance

Attributes

instances[RW]
reserved_instances[RW]
count[RW]
engine[RW]
id[RW]
instance_type[RW]
multi_az[RW]
name[RW]

Public Class Methods

get_instances() click to toggle source
# File lib/aws_auditor/rds_instance.rb, line 26
def self.get_instances
  return @instances if @instances
  @instances = rds.describe_db_instances[:db_instances].map do |instance|
    next unless instance[:db_instance_status].to_s == 'available'
    new(instance)
  end.compact
end
get_reserved_instances() click to toggle source
# File lib/aws_auditor/rds_instance.rb, line 34
def self.get_reserved_instances
  return @reserved_instances if @reserved_instances
  @reserved_instances = rds.describe_reserved_db_instances[:reserved_db_instances].map do |instance|
    next unless instance[:state].to_s == 'active'
    new(instance)
  end.compact
end
new(rds_instance) click to toggle source
# File lib/aws_auditor/rds_instance.rb, line 13
def initialize(rds_instance)
  @id = rds_instance[:db_instance_identifier] || rds_instance[:reserved_db_instances_offering_id]
  @name = rds_instance[:db_instance_identifier] || rds_instance[:db_name]
  @multi_az = rds_instance[:multi_az] ? "Multi-AZ" : "Single-AZ"
  @instance_type = rds_instance[:db_instance_class]
  @engine = rds_instance[:engine] || rds_instance[:product_description]
  @count = rds_instance[:db_instance_count] || 1
end

Public Instance Methods

to_s() click to toggle source
# File lib/aws_auditor/rds_instance.rb, line 22
def to_s
  "#{engine_helper} #{multi_az} #{instance_type}"
end

Private Instance Methods

engine_helper() click to toggle source
# File lib/aws_auditor/rds_instance.rb, line 42
def engine_helper
  if engine.downcase.include? "post"
    return "PostgreSQL"
  elsif engine.downcase.include? "mysql"
    return "MySQL"
  end
end