def get_s3_client():
session_kwargs = {}<EOL>if hasattr(settings, '<STR_LIT>'):<EOL><INDENT>session_kwargs['<STR_LIT>'] = settings.AWS_ACCESS_KEY_ID<EOL><DEDENT>if hasattr(settings, '<STR_LIT>'):<EOL><INDENT>session_kwargs['<STR_LIT>'] = settings.AWS_SECRET_ACCESS_KEY<EOL><DEDENT>boto3.setup_default_session(**session_kwargs)<EOL>s3_kwargs = {}<EOL>if hasattr(settings, '<STR_LIT>'):<EOL><INDENT>s3_kwargs['<STR_LIT>'] = settings.AWS_S3_ENDPOINT<EOL><DEDENT>elif hasattr(settings, '<STR_LIT>'):<EOL><INDENT>if hasattr(settings, '<STR_LIT>') and settings.AWS_S3_USE_SSL is False:<EOL><INDENT>protocol = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>protocol = "<STR_LIT>"<EOL><DEDENT>s3_kwargs['<STR_LIT>'] = "<STR_LIT>".format(<EOL>protocol,<EOL>settings.AWS_S3_HOST<EOL>)<EOL><DEDENT>if hasattr(settings, "<STR_LIT>"):<EOL><INDENT>s3_kwargs['<STR_LIT>'] = settings.AWS_REGION<EOL><DEDENT>s3_client = boto3.client('<STR_LIT>', **s3_kwargs)<EOL>s3_resource = boto3.resource('<STR_LIT>', **s3_kwargs)<EOL>return s3_client, s3_resource<EOL>
A DRY place to make sure AWS credentials in settings override
environment based credentials.  Boto3 will fall back to:
http://boto3.readthedocs.io/en/latest/guide/configuration.html