diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index 7ef1a7401..b622ff7f1 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -72,7 +72,7 @@ class CmdDataSync(CmdBase): def _get_bucket_aws(self): """ get a bucket object, aws """ - conn = S3Connection(self.config.aws_access_key_id, self.config.aws_secret_access_key, host='s3-us-west-2.amazonaws.com') + conn = S3Connection(self.config.aws_access_key_id, self.config.aws_secret_access_key, host=self.config.aws_region_host) bucket_name = self.config.storage_bucket bucket = conn.lookup(bucket_name) if bucket is None: diff --git a/dvc/config.py b/dvc/config.py index 7082c0a3b..4590cfab0 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -65,6 +65,21 @@ class Config(ConfigI): def aws_secret_access_key(self): return self._config['AWS']['SecretAccessKey'] + @property + def aws_region_host(self): + """ get the region host needed for s3 access + + See notes http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region + """ + + region = self._config['AWS']['Region'] + if region is None or region == '': + return 's3.amazonaws.com' + if region == 'us-east-1': + return 's3.amazonaws.com' + return 's3.%s.amazonaws.com' % region + + @property def storage_path(self): """ get storage path