(credentials_file: str)
return keys
Extract AWS secrets from configuration files.

    Read an ini-style configuration file and return a set with all found AWS
    secret access keys.
Extract AWS secrets from configuration files.
Extract AWS secrets from configuration files .
def get_aws_secrets_from_file(credentials_file: str) -> Set[str]:
    """Extract AWS secrets from configuration files.

    Read an ini-style configuration file and return a set with all found AWS
    secret access keys.
    """
    aws_credentials_file_path = os.path.expanduser(credentials_file)
    if not os.path.exists(aws_credentials_file_path):
        return set()

    parser = configparser.ConfigParser()
    try:
        parser.read(aws_credentials_file_path)
    except configparser.MissingSectionHeaderError:
        return set()

    keys = set()
    for section in parser.sections():
        for var in (
            'aws_secret_access_key', 'aws_security_token',
            'aws_session_token',
        ):
            try:
                key = parser.get(section, var).strip()
                if key:
                    keys.add(key)
            except configparser.NoOptionError:
                pass
    return keys
def get_aws_secrets_from_file ( credentials_file : str ) -> Set [ str ] : aws_credentials_file_path = os . path . expanduser ( credentials_file ) if not os . path . exists ( aws_credentials_file_path ) : return set ( ) parser = configparser . ConfigParser ( ) try : parser . read ( aws_credentials_file_path ) except configparser . MissingSectionHeaderError : return set ( ) keys = set ( ) for section in parser . sections ( ) : for var in ( 'aws_secret_access_key' , 'aws_security_token' , 'aws_session_token' , ) : try : key = parser . get ( section , var ) . strip ( ) if key : keys . add ( key ) except configparser . NoOptionError : pass return keys