botocore
botocore copied to clipboard
botocore.credentials should log "Found credentials" consistently
As I've been trying to debug an issue with an instance metadata credentials error, I looked at bumping the loglevel of botocore.credentials. That's when I noticed that most concrete CredentialProvider implementations log a message saying where credentials were found.
logger.info("Found credentials in environment variables")
logger.info('Found credentials in AWS_CREDENTIAL_FILE.')
logger.info("Found credentials in shared credentials file: %s", self._creds_filename)
logger.info("Credentials found in config file: %s", self._config_filename)
logger.info("Found credentials in boto config file: %s", filename)
However, InstanceMetadataProvider logs at the debug level. AssumeRoleProvider, AssumeRoleWithWebIdentityProvider, ContainerProvider and ProcessProvider don't log at all. (or if they do, it's not clear from reading the code -- I didn't actually trigger every provider to make this report.)
In my opinion, this logging should be consistent across credential providers, so that it's clear where credentials are actually coming from.
@kojiromike - Thank you for your post. This seems like a reasonable idea to me. I would mark this as enhancement.
I stumbled here looking for the source of a log message "Found credentials in environment variables" , now it is clear it was probably from boto module.
Please, please move them to debug level. It's the only log line that my project logs that doesn't come from it :sweat_smile:
Until Fixed
import boto3
import logging
boto3.set_stream_logger(name='botocore.credentials', level=logging.ERROR)