- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_bucket.py
More file actions
Latest commit
19 lines (15 loc) · 552 Bytes
/
Copy pathcreate_bucket.py
File metadata and controls
19 lines (15 loc) · 552 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
importboto3
s3_client=boto3.client('s3')
importuuid
defcreate_bucket_name(bucket_prefix):
return''.join([bucket_prefix, str(uuid.uuid4())])
defcreate_bucket(bucket_prefix, s3_connection):
session=boto3.session.Session()
current_region=session.region_name
bucket_name=create_bucket_name(bucket_prefix)
bucket_response=s3_connection.create_bucket(
Bucket=bucket_name,
CreateBucketConfiguration={
'LocationConstraint': current_region})
print(bucket_name, current_region)
returnbucket_name, bucket_response