Skip to content

Commit 3059948

Browse files
authored
Update S3 create_bucket.py example to support regions
Merge pull request #738 from awsdocs/py_create_bucket
2 parents cf4a37e + f92b94d commit 3059948

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/example_code/s3/create_bucket.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ def create_bucket(bucket_name, region=None):
3939
"""
4040

4141
# Create bucket
42-
s3_client = boto3.client('s3')
4342
try:
4443
if region is None:
44+
s3_client = boto3.client('s3')
4545
s3_client.create_bucket(Bucket=bucket_name)
4646
else:
47+
s3_client = boto3.client('s3', region_name=region)
4748
location = {'LocationConstraint': region}
4849
s3_client.create_bucket(Bucket=bucket_name,
4950
CreateBucketConfiguration=location)

0 commit comments

Comments
 (0)