in pyqldbsamples/export_journal.py [0:0]
def create_s3_bucket_if_not_exists(bucket_name, s3_resource):
"""
Create a S3 bucket if one with the given bucket_name does not exists.
:type bucket_name: str
:param bucket_name: The name of the bucket to check.
:type s3_resource: :py:class:`botocore.client.BaseClient`
:param s3_resource: A low-level S3 resource service client.
"""
if not does_bucket_exists(bucket_name, s3_resource):
logger.info('S3 bucket {} does not exist. Creating it now.'.format(bucket_name))
s3_client = client('s3')
s3_region = s3_client.meta.region_name
try:
s3_resource.create_bucket(Bucket=bucket_name,
CreateBucketConfiguration={'LocationConstraint': s3_region})
logger.info('Bucket with name: {} created.'.format(bucket_name))
except Exception as e:
logger.info('Unable to create S3 bucket named: {}'.format(bucket_name))
raise e