【发布时间】:2021-10-23 12:07:03
【问题描述】:
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.')
我正在创建一个 S3 存储桶,但由于某种原因,Pylance 给我一个错误,抱怨它无法访问该变量。
【问题讨论】: