How to use the awsume.awsumepy.lib.aws_files.get_aws_files function in awsume

To help you get started, we’ve selected a few awsume examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trek10inc / awsume / test / unit / awsume / awsumepy / lib / test_aws_files.py View on Github external
def test_get_aws_files_environment():
    args = argparse.Namespace(config_file=None, credentials_file=None)
    config = {}

    config_file, credentials_file = aws_files.get_aws_files(args, config)

    assert config_file == str(Path('my/config/file'))
    assert credentials_file == str(Path('my/credentials/file'))
github trek10inc / awsume / test / unit / awsume / awsumepy / lib / test_aws_files.py View on Github external
def test_get_aws_files_args():
    args = argparse.Namespace(config_file='my/config/file', credentials_file='my/credentials/file')
    config = {}

    config_file, credentials_file = aws_files.get_aws_files(args, config)

    assert config_file == str(Path('my/config/file'))
    assert credentials_file == str(Path('my/credentials/file'))
github trek10inc / awsume / test / unit / awsume / awsumepy / lib / test_aws_files.py View on Github external
def test_get_aws_files():
    args = argparse.Namespace(config_file=None, credentials_file=None)
    config = {}

    config_file, credentials_file = aws_files.get_aws_files(args, config)

    assert config_file == str(Path(constants.DEFAULT_CONFIG_FILE))
    assert credentials_file == str(Path(constants.DEFAULT_CREDENTIALS_FILE))
github trek10inc / awsume / test / unit / awsume / awsumepy / lib / test_aws_files.py View on Github external
def test_get_aws_files_config():
    args = argparse.Namespace(config_file=None, credentials_file=None)
    config = {
        'config-file': 'my/config/file',
        'credentials-file': 'my/credentials/file',
    }

    config_file, credentials_file = aws_files.get_aws_files(args, config)

    assert config_file == str(Path('my/config/file'))
    assert credentials_file == str(Path('my/credentials/file'))
github trek10inc / awsume / awsume / awsumepy / app.py View on Github external
def get_profiles(self, args: argparse.Namespace) -> dict:
        logger.debug('Gathering profiles')
        config_file, credentials_file = get_aws_files(args, self.config)
        self.plugin_manager.hook.pre_collect_aws_profiles(
            config=self.config,
            arguments=args,
            credentials_file=credentials_file,
            config_file=config_file,
        )
        aws_profiles_result = self.plugin_manager.hook.collect_aws_profiles(
            config=self.config,
            arguments=args,
            credentials_file=credentials_file,
            config_file=config_file,
        )
        profiles = aggregate_profiles(aws_profiles_result)
        self.plugin_manager.hook.post_collect_aws_profiles(
            config=self.config,
            arguments=args,
github trek10inc / awsume / awsume / autoawsume / process.py View on Github external
def kill(arguments: argparse.Namespace):
    _, credentials_file = get_aws_files(None, None)
    if arguments.profile_name:
        logger.debug('Stoping auto-refresh of profile {}'.format(arguments.profile_name))
        delete_section('autoawsume-{}'.format(arguments.profile_name), credentials_file)
        profiles = read_aws_file(credentials_file)
        profile_names = [_ for _ in profiles]
        if any(['autoawsume-' in _ for _ in profile_names]):
            print('Stop {}'.format(arguments.profile_name))
            return
        else:
            logger.debug('There were not more autoawsume profiles, stopping autoawsume')
            print('Kill')
            kill_autoawsume()
    else:
        logger.debug('Stopping all auto refreshing and removing autoawsume profiles')
        kill_autoawsume()
        profiles = read_aws_file(credentials_file)
github trek10inc / awsume / awsume / autoawsume / main.py View on Github external
def main():
    configure_logger()

    logger.debug('Getting credentials file')
    _, credentials_file = get_aws_files(None, None)
    logger.debug('Credentials file: {}'.format(credentials_file))

    while True:
        logger.info('Scanning profiles')
        credentials = configparser.ConfigParser()
        credentials.read(credentials_file)
        auto_profiles = {k: dict(v) for k, v in credentials._sections.items() if k.startswith('autoawsume-')}

        expirations = []
        for profile_name, auto_profile in auto_profiles.items():
            logger.info('Looking at profile [{}]: {}'.format(profile_name, redact_profile(auto_profile)))
            expiration = datetime.strptime(auto_profile['expiration'], '%Y-%m-%d %H:%M:%S')
            source_expiration = datetime.strptime(auto_profile['source_expiration'], '%Y-%m-%d %H:%M:%S')
            if source_expiration < datetime.now():
                logger.debug('Source is expired')
                if expiration < datetime.now():