Просмотр исходного кода

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

Nuwan Goonasekera 8 лет назад
Родитель
Сommit
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):
         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)