Class: AwsAuditor::RDSInstance

Inherits:
Object
  • Object
show all
Extended by:
InstanceHelper, RDSWrapper
Defined in:
lib/aws_auditor/rds_instance.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes included from RDSWrapper

#rds

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InstanceHelper

compare, instance_count_hash, instance_hash, reserved_instance_hash

Constructor Details

#initialize(rds_instance) ⇒ RDSInstance

Returns a new instance of RDSInstance.



13
14
15
16
17
18
19
20
# 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

Class Attribute Details

.instancesObject

Returns the value of attribute instances.



9
10
11
# File 'lib/aws_auditor/rds_instance.rb', line 9

def instances
  @instances
end

.reserved_instancesObject

Returns the value of attribute reserved_instances.



9
10
11
# File 'lib/aws_auditor/rds_instance.rb', line 9

def reserved_instances
  @reserved_instances
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



12
13
14
# File 'lib/aws_auditor/rds_instance.rb', line 12

def count
  @count
end

#engineObject

Returns the value of attribute engine.



12
13
14
# File 'lib/aws_auditor/rds_instance.rb', line 12

def engine
  @engine
end

#idObject

Returns the value of attribute id.



12
13
14
# File 'lib/aws_auditor/rds_instance.rb', line 12

def id
  @id
end

#instance_typeObject

Returns the value of attribute instance_type.



12
13
14
# File 'lib/aws_auditor/rds_instance.rb', line 12

def instance_type
  @instance_type
end

#multi_azObject

Returns the value of attribute multi_az.



12
13
14
# File 'lib/aws_auditor/rds_instance.rb', line 12

def multi_az
  @multi_az
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/aws_auditor/rds_instance.rb', line 12

def name
  @name
end

Class Method Details

.get_instancesObject



26
27
28
29
30
31
32
# 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_instancesObject



34
35
36
37
38
39
40
# 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

Instance Method Details

#to_sObject



22
23
24
# File 'lib/aws_auditor/rds_instance.rb', line 22

def to_s
  "#{engine_helper} #{multi_az} #{instance_type}"
end