-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathcreateS3Bucket.py
More file actions
29 lines (24 loc) · 786 Bytes
/
createS3Bucket.py
File metadata and controls
29 lines (24 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import boto3
import os
import datetime
class s3Bucket:
def __init__(self, bucketName: str) -> None:
self.bucketName = bucketName
def createS3Bucket(self):
try:
client = boto3.client("s3")
client.create_bucket(
ACL="private",
Bucket=self.bucketName,
CreateBucketConfiguration={"LocationConstraint": "us-west-1"},
)
except Exception as err:
print(err)
else:
print("S3 bucket creation Successful!")
if __name__ == "__main__":
date = datetime.datetime.now()
current_time = "{}{}{}".format(date.month, date.day, date.year)
bucketName = "yourName{}".format(current_time)
obj = s3Bucket(bucketName)
obj.createS3Bucket()