fix aws region bug

This commit is contained in:
Earl Hathaway
2017-04-16 22:15:24 -07:00
parent f84cbd0d17
commit 0772e41638
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -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:
+15
View File
@@ -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