s3 = boto3.resource("s3")
s3_client = boto3.client('s3')
name = "devopsProject"
bucketName = (name + str(uuid.uuid4()))
def createBucket():
##### Create the S3 Bucket #####
try:
print('Creating S3 Bucket...')
new_bucket = s3.create_bucket(
Bucket=bucketName,
CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'},
ACL='public-read',
)
print('Bucket successfully created.')
except Exception as e:
if e.response['Error']['Code'] == 'BucketAlreadyExists':
print('This bucket name is already in use')
else:
print('An error occurred during S3 Bucket creation.')
I am creating an S3 bucket but for some reason, Pylance is giving me an error complaining it cant access the variable.