'Load AWS credentials.
An optional boto_session can be provided, but that\'s usually for testing.
An optional profile_name can be provided for config files that have multiple sets
of credentials.'

def load_credentials(self, boto_session=None, profile_name=None):

    if (not boto_session):
        if profile_name:
            self.boto_session = boto3.Session(profile_name=profile_name, region_name=self.aws_region)
        elif (os.environ.get('AWS_ACCESS_KEY_ID') and os.environ.get('AWS_SECRET_ACCESS_KEY')):
            region_name = (os.environ.get('AWS_DEFAULT_REGION') or self.aws_region)
            session_kw = {'aws_access_key_id': os.environ.get('AWS_ACCESS_KEY_ID'), 'aws_secret_access_key': os.environ.get('AWS_SECRET_ACCESS_KEY'), 'region_name': region_name}
            if os.environ.get('AWS_SESSION_TOKEN'):
                session_kw['aws_session_token'] = os.environ.get('AWS_SESSION_TOKEN')
            self.boto_session = boto3.Session(**session_kw)
        else:
            self.boto_session = boto3.Session(region_name=self.aws_region)
        logger.debug('Loaded    boto    session    from    config:    %s', boto_session)
    else:
        logger.debug('Using    provided    boto    session:    %s', boto_session)
        self.boto_session = boto_session
    self.aws_region = self.boto_session.region_name
    if (self.boto_session.region_name not in LAMBDA_REGIONS):
        print('Warning!    AWS    Lambda    may    not    be    available    in    this    AWS    Region!')
    if (self.boto_session.region_name not in API_GATEWAY_REGIONS):
        print('Warning!    AWS    API    Gateway    may    not    be    available    in    this    AWS    Region!')
