Skip to content

Commit 892450d

Browse files
committed
fix(database+registry): check for S3 bucket name before creating it
1 parent 95746aa commit 892450d

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

database/templates/create_bucket

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/usr/bin/env python
2+
23
import boto
34
import sys
45
from boto.s3.connection import OrdinaryCallingFormat
56

6-
conn = boto.connect_s3(host='{{ getv "/deis/store/gateway/host" }}',
7-
port={{ getv "/deis/store/gateway/port" }},
8-
is_secure=False,
9-
calling_format=OrdinaryCallingFormat(),
10-
)
11-
bucket = sys.argv[1]
127

13-
if not bucket in conn.get_all_buckets():
14-
conn.create_bucket(bucket)
8+
conn = boto.connect_s3(
9+
host='{{ getv "/deis/store/gateway/host" }}',
10+
port={{ getv "/deis/store/gateway/port" }},
11+
is_secure=False,
12+
calling_format=OrdinaryCallingFormat())
13+
name = sys.argv[1]
14+
15+
if name not in (bucket.name for bucket in conn.get_all_buckets()):
16+
conn.create_bucket(name)

registry/templates/create_bucket

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#!/usr/bin/env python
2+
23
import boto
34
import sys
45
from boto.s3.connection import OrdinaryCallingFormat
56

6-
conn = boto.connect_s3(aws_access_key_id='{{ getv "/deis/store/gateway/accessKey" }}',
7-
aws_secret_access_key='{{ getv "/deis/store/gateway/secretKey" }}',
8-
host='{{ getv "/deis/store/gateway/host" }}',
9-
port={{ getv "/deis/store/gateway/port" }},
10-
is_secure=False,
11-
calling_format=OrdinaryCallingFormat(),
12-
)
13-
bucket = sys.argv[1]
7+
conn = boto.connect_s3(
8+
aws_access_key_id='{{ getv "/deis/store/gateway/accessKey" }}',
9+
aws_secret_access_key='{{ getv "/deis/store/gateway/secretKey" }}',
10+
host='{{ getv "/deis/store/gateway/host" }}',
11+
port={{ getv "/deis/store/gateway/port" }},
12+
is_secure=False,
13+
calling_format=OrdinaryCallingFormat())
14+
name = sys.argv[1]
1415

15-
if not bucket in conn.get_all_buckets():
16-
conn.create_bucket(bucket)
16+
if name not in (bucket.name for bucket in conn.get_all_buckets()):
17+
conn.create_bucket(name)

0 commit comments

Comments
 (0)