Esempio n. 1
0
def get_full_db_credentials(eb_environment_name):
    """ reads in the database credentials for the project and dynamically identifies the hostname
    parameter. """
    with open(get_db_credentials_file_path(eb_environment_name), 'r') as f:
        credentials = json.load(f)
    credentials['RDS_HOSTNAME'] = get_db_info(eb_environment_name)['Endpoint']['Address']
    return credentials
Esempio n. 2
0
def write_rds_credentials(eb_environment_name, credentials, test_for_existing_files):
    """ Writes to the database credentials file for the environment. """
    db_credentials_path = get_db_credentials_file_path(eb_environment_name)
    if test_for_existing_files and os.path.exists(db_credentials_path):
        msg = "Encountered a file at %s, abortiing." % db_credentials_path
        log.error("Encountered a file at %s, abortiing.")
        raise Exception(msg)

    with open(db_credentials_path, 'w') as f:
        json.dump(credentials, f, indent=1)
        log.info("database credentials have been written to %s" % db_credentials_path)