瀏覽代碼

Add special handling for us-east-1 due to S3 bug

Nuwan Goonasekera 8 年之前
父節點
當前提交
3e86ca1a11
共有 1 個文件被更改,包括 13 次插入6 次删除
  1. 13 6
      cloudbridge/cloud/providers/aws/services.py

+ 13 - 6
cloudbridge/cloud/providers/aws/services.py

@@ -377,12 +377,19 @@ class AWSObjectStoreService(BaseObjectStoreService):
 
 
     def create(self, name, location=None):
     def create(self, name, location=None):
         AWSBucket.assert_valid_resource_name(name)
         AWSBucket.assert_valid_resource_name(name)
-
-        self.iface.create(
-            'create_bucket', Bucket=name,
-            CreateBucketConfiguration={
-                'LocationConstraint': location or self.provider.region_name
-            })
+        loc_constraint = location or self.provider.region_name
+        # Due to an API issue in S3, specifying us-east-1 as a
+        # LocationConstraint results in an InvalidLocationConstraint.
+        # Therefore, it must be special-cased and omitted altogether.
+        # See: https://github.com/boto/boto3/issues/125
+        if loc_constraint == 'us-east-1':
+            self.iface.create('create_bucket', Bucket=name)
+        else:
+            self.iface.create(
+                'create_bucket', Bucket=name,
+                CreateBucketConfiguration={
+                    'LocationConstraint': loc_constraint
+                })
         return self.get(name)
         return self.get(name)