Class: SportNginAwsAuditor::RDSInstance
- Inherits:
-
Object
- Object
- SportNginAwsAuditor::RDSInstance
- Extended by:
- AWSWrapper, InstanceHelper, RDSWrapper
- Defined in:
- lib/sport_ngin_aws_auditor/rds_instance.rb
Class Attribute Summary collapse
-
.instances ⇒ Object
Returns the value of attribute instances.
-
.reserved_instances ⇒ Object
Returns the value of attribute reserved_instances.
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.
-
#tag_value ⇒ Object
Returns the value of attribute tag_value.
Attributes included from RDSWrapper
Attributes included from AWSWrapper
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(rds_instance, account_id = nil, tag_name = nil, rds = nil) ⇒ RDSInstance
constructor
A new instance of RDSInstance.
- #no_reserved_instance_tag_value ⇒ Object
- #to_s ⇒ Object
Methods included from InstanceHelper
add_instances_with_tag_to_hash, compare, filter_instance_without_tags, filter_instances_with_tags, gather_instance_tag_date, instance_count_hash, instance_hash, reserved_instance_hash
Methods included from AWSWrapper
Constructor Details
#initialize(rds_instance, account_id = nil, tag_name = nil, rds = nil) ⇒ RDSInstance
Returns a new instance of RDSInstance.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 14 def initialize(rds_instance, account_id=nil, tag_name=nil, rds=nil) if rds_instance.class.to_s == "Aws::RDS::Types::ReservedDBInstance" self.id = rds_instance.reserved_db_instances_offering_id self.multi_az = rds_instance.multi_az ? "Multi-AZ" : "Single-AZ" self.instance_type = rds_instance.db_instance_class self.engine = rds_instance.product_description self.count = 1 elsif rds_instance.class.to_s == "Aws::RDS::Types::DBInstance" self.id = rds_instance.db_instance_identifier self.multi_az = rds_instance.multi_az ? "Multi-AZ" : "Single-AZ" self.instance_type = rds_instance.db_instance_class self.engine = rds_instance.engine self.count = 1 if tag_name region = rds_instance.availability_zone.split(//).first(9).join region = "us-east-1" if region == "Multiple" arn = "arn:aws:rds:#{region}:#{account_id}:db:#{self.id}" # go through to see if the tag we're looking for is one of them rds.(resource_name: arn).tag_list.each do |tag| if tag.key == tag_name self.tag_value = tag.value end end end end end |
Class Attribute Details
.instances ⇒ Object
Returns the value of attribute instances.
10 11 12 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 10 def instances @instances end |
.reserved_instances ⇒ Object
Returns the value of attribute reserved_instances.
10 11 12 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 10 def reserved_instances @reserved_instances end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
13 14 15 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 13 def count @count end |
#engine ⇒ Object
Returns the value of attribute engine.
13 14 15 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 13 def engine @engine end |
#id ⇒ Object
Returns the value of attribute id.
13 14 15 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 13 def id @id end |
#instance_type ⇒ Object
Returns the value of attribute instance_type.
13 14 15 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 13 def instance_type @instance_type end |
#multi_az ⇒ Object
Returns the value of attribute multi_az.
13 14 15 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 13 def multi_az @multi_az end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 13 def name @name end |
#tag_value ⇒ Object
Returns the value of attribute tag_value.
13 14 15 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 13 def tag_value @tag_value end |
Class Method Details
.get_instances(tag_name = nil) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 47 def self.get_instances(tag_name=nil) return @instances if @instances account_id = get_account_id @instances = rds.describe_db_instances.db_instances.map do |instance| next unless instance.db_instance_status.to_s == 'available' new(instance, account_id, tag_name, rds) end.compact end |
.get_reserved_instances ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 56 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
#no_reserved_instance_tag_value ⇒ Object
64 65 66 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 64 def no_reserved_instance_tag_value @tag_value end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/sport_ngin_aws_auditor/rds_instance.rb', line 43 def to_s "#{engine_helper} #{multi_az} #{instance_type}" end |