Sha256: 4ae1f7e0593da7ab5095f75840312b1dc458d79c9f3150c7a9af6cccdcdbef82

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module AwsClient
  class RdsWrapper < AwsClient::Wrapper

    def instance_by_database_name(database_name)
      all_instances.select{|db_instance| db_instance.db_name == database_name && db_instance.read_replica_source_db_instance_identifier.nil? }.first
    end

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

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

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

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

    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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws_client-0.0.93 lib/rds_wrapper.rb