From 4ee615e5b49ce18ff114afd74eac1cc6eaac8ed7 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Wed, 7 Nov 2018 19:11:18 -0600 Subject: [PATCH] Prefer using ENV_VARS before dvc config file --- dvc/remote/s3.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/dvc/remote/s3.py b/dvc/remote/s3.py index 7868b1d3d..56e75adb4 100644 --- a/dvc/remote/s3.py +++ b/dvc/remote/s3.py @@ -47,15 +47,22 @@ class RemoteS3(RemoteBase): ) self.url = config.get(Config.SECTION_REMOTE_URL, storagepath) - self.region = config.get(Config.SECTION_AWS_REGION) - self.profile = config.get(Config.SECTION_AWS_PROFILE) + + self.region = ( + os.environ.get('AWS_DEFAULT_REGION') or + config.get(Config.SECTION_AWS_REGION) + ) + + self.profile = ( + os.environ.get('AWS_PROFILE') or + config.get(Config.SECTION_AWS_PROFILE) + ) + self.endpoint_url = config.get(Config.SECTION_AWS_ENDPOINT_URL) - # backward compatibility - credentialpath = config.get(Config.SECTION_AWS_CREDENTIALPATH) - - if credentialpath: - os.environ['AWS_SHARED_CREDENTIALS_FILE'] = credentialpath + shared_creds = config.get(Config.SECTION_AWS_CREDENTIALPATH) + if shared_creds: + os.environ.setdefault('AWS_SHARED_CREDENTIALS_FILE', shared_creds) @staticmethod def compat_config(config):