diff --git a/fence/blueprints/data/indexd.py b/fence/blueprints/data/indexd.py index f2978f56d..09c81f26e 100755 --- a/fence/blueprints/data/indexd.py +++ b/fence/blueprints/data/indexd.py @@ -349,8 +349,9 @@ def init_multipart_upload(key, expires_in=None, bucket=None): Returns: uploadId(str) """ - bucket = bucket or flask.current_app.config["DATA_UPLOAD_BUCKET"] - if not bucket: + try: + bucket = bucket or flask.current_app.config["DATA_UPLOAD_BUCKET"] + except KeyError: raise InternalError( "fence not configured with data upload bucket; can't create signed URL" ) diff --git a/fence/resources/aws/boto_manager.py b/fence/resources/aws/boto_manager.py index 1fee8e8ca..215040e9c 100644 --- a/fence/resources/aws/boto_manager.py +++ b/fence/resources/aws/boto_manager.py @@ -18,30 +18,28 @@ class BotoManager(object): ) def __init__(self, config, buckets, logger): - self.sts_client = client("sts", **config) - self.s3_client = client("s3", **config) + default = list(config.values())[0] + self.sts_client = client("sts", **default) + self.s3_client = client("s3", **default) self.s3_clients = self.create_s3_clients(config, buckets) self.logger = logger self.ec2 = None self.iam = None def create_s3_clients(self, config, buckets): - s3_clients = {} - for creds in config: - if config[creds]['aws'] == 'true': - s3_clients = {'default': self.s3_client} + s3_clients = {'default': self.s3_client} for bucket in buckets: cred_name = buckets[bucket]['cred'] - keys = config[cred_name] - if 'aws' in keys: - keys.pop('aws') + creds = {} + if cred_name != '*': + creds = config[cred_name] if 'endpoint_url' in buckets[bucket]: endpoint_url = buckets[bucket]['endpoint_url'] - s3_clients[bucket] = client('s3', **keys, endpoint_url=endpoint_url) + s3_clients[bucket] = client('s3', **creds, endpoint_url=endpoint_url) else: - s3_clients[bucket] = client('s3', **keys) + s3_clients[bucket] = client('s3', **creds) return s3_clients def get_s3_client(self, bucket):