Class: AwsAuditor::RDSInstance
- Inherits:
-
Object
- Object
- AwsAuditor::RDSInstance
- Extended by:
- InstanceHelper, RDSWrapper
- Defined in:
- lib/aws_auditor/rds_instance.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instance_type ⇒ Object
Returns the value of attribute instance_type.
-
#multi_az ⇒ Object
Returns the value of attribute multi_az.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes included from RDSWrapper
Class Method Summary collapse
Instance Method Summary collapse
- #engine_helper ⇒ Object
-
#initialize(rds_instance) ⇒ RDSInstance
constructor
A new instance of RDSInstance.
- #multi_az? ⇒ Boolean
- #to_s ⇒ Object
Methods included from InstanceHelper
compare, instance_count_hash, instance_hash
Constructor Details
#initialize(rds_instance) ⇒ RDSInstance
Returns a new instance of RDSInstance.
9 10 11 12 13 14 15 16 |
# File 'lib/aws_auditor/rds_instance.rb', line 9 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] @instance_type = rds_instance[:db_instance_class] @engine = rds_instance[:engine] || rds_instance[:product_description] @count = rds_instance[:db_instance_count] || 1 end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
8 9 10 |
# File 'lib/aws_auditor/rds_instance.rb', line 8 def count @count end |
#engine ⇒ Object
Returns the value of attribute engine.
8 9 10 |
# File 'lib/aws_auditor/rds_instance.rb', line 8 def engine @engine end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/aws_auditor/rds_instance.rb', line 8 def id @id end |
#instance_type ⇒ Object
Returns the value of attribute instance_type.
8 9 10 |
# File 'lib/aws_auditor/rds_instance.rb', line 8 def instance_type @instance_type end |
#multi_az ⇒ Object
Returns the value of attribute multi_az.
8 9 10 |
# File 'lib/aws_auditor/rds_instance.rb', line 8 def multi_az @multi_az end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/aws_auditor/rds_instance.rb', line 8 def name @name end |
Class Method Details
.get_instances ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/aws_auditor/rds_instance.rb', line 34 def self.get_instances instances = rds.describe_db_instances[:db_instances] instances.map do |instance| next unless instance[:db_instance_status].to_s == 'available' new(instance) end end |
.get_reserved_instances ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/aws_auditor/rds_instance.rb', line 42 def self.get_reserved_instances instances = rds.describe_reserved_db_instances[:reserved_db_instances] instances.map do |instance| next unless instance[:state].to_s == 'active' new(instance) end end |
Instance Method Details
#engine_helper ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/aws_auditor/rds_instance.rb', line 26 def engine_helper if engine.downcase.include? "post" return "PostgreSQL" elsif engine.downcase.include? "mysql" return "MySQL" end end |
#multi_az? ⇒ Boolean
22 23 24 |
# File 'lib/aws_auditor/rds_instance.rb', line 22 def multi_az? multi_az ? "Multi-AZ" : "Single-AZ" end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/aws_auditor/rds_instance.rb', line 18 def to_s "#{engine_helper} #{multi_az?} #{instance_type}" end |