#1 Activates Boto for use and directs it to s3 storage
import boto3
s3 = boto3.resource('s3')
#2 Python ask user to create a bucket name
bucket_name = input("Select a bucket name (must be all lowercase). ")
#3 Python gathers bucket names within s3 and prints list
for bucket in s3.buckets.all():
print(bucket.name)
bucket = list(s3.buckets.all())
#4 Checks bucket_name against the names with s3 to see if it matches any names, informs them if there is a match, and ask to create another name. If the name doesn't it create a new bucket with new unique name.
if bucket_name in bucket:
print("The name you selected is already taken, please choose a different name")
bucket_name = input('Select another bucket name (must be all lowercase). ')
else:
print('Your new bucket is named',bucket_name,"!")
def create_bucket():
s3_client = boto3.client('s3')
s3_client.create_bucket(Bucket=bucket_name)
create_bucket()