lib/rds_wrapper.rb in aws_client-0.1.1 vs lib/rds_wrapper.rb in aws_client-0.1.2
- old
+ new
@@ -1,10 +1,13 @@
module AwsClient
class RdsWrapper < AwsClient::Wrapper
def instance_by_database_name(database_name, is_master = true)
- selector = is_master ? :last : :first ## hacky - we need a much better way of targetting rds instances.
- return all_instances.select{|db_instance| db_instance.db_name == database_name }.send(selector)
+ if is_master
+ all_instances.select{|db_instance| db_instance.db_name == database_name && db_instance.read_replica_source_db_instance_identifier.nil? }.first
+ else
+ all_instances.select{|db_instance| db_instance.db_name == database_name && !db_instance.read_replica_source_db_instance_identifier.nil? }.first
+ end
end
def instance_data_by_vpc_id(vpc_id)
return all_instances.select{|instance| instance.db_subnet_group.vpc_id = vpc_id }
end