Class: AwsClient::RdsWrapper

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/rds_wrapper.rb

Instance Attribute Summary

Attributes inherited from Wrapper

#client

Instance Method Summary collapse

Methods inherited from Wrapper

#initialize

Constructor Details

This class inherits a constructor from AwsClient::Wrapper

Instance Method Details

#all_instancesObject



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

def all_instances
  @all_instances ||= get_all_instances.collect{|raw_instance| raw_instance.db_instances.flatten }.flatten
end

#get_all_instancesObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/rds_wrapper.rb', line 26

def get_all_instances
  all_instances = []
  pages = client.describe_db_instances
  all_instances << pages.data
  while pages.next_page?
    pages = pages.next_page
    @all_instances << pages.data
  end
  return all_instances    
end

#instance_by_database_name(database_name) ⇒ Object



4
5
6
# File 'lib/rds_wrapper.rb', line 4

def instance_by_database_name(database_name)
  return all_instances.select{|db_instance| db_instance.db_name == database_name }.last
end

#instance_data_by_vpc_id(vpc_id) ⇒ Object



8
9
10
# File 'lib/rds_wrapper.rb', line 8

def instance_data_by_vpc_id(vpc_id)
  return all_instances.select{|instance| instance.db_subnet_group.vpc_id = vpc_id }
end

#instance_endpoint(instance) ⇒ Object



12
13
14
15
# File 'lib/rds_wrapper.rb', line 12

def instance_endpoint(instance)
  return "UNDEFINED" if instance.nil?
  return instance.endpoint.address
end

#instance_endpoint_for_named_database(database_name) ⇒ Object



17
18
19
20
# File 'lib/rds_wrapper.rb', line 17

def instance_endpoint_for_named_database(database_name)
  instance = instance_by_database_name(database_name)
  return instance_endpoint(instance)
end