def does_bucket_exists()

in pyqldbsamples/export_journal.py [0:0]


def does_bucket_exists(bucket_name, s3_resource):
    """
    Check whether a bucket exists in S3.

    :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.

    :rtype: bool
    :return: If the bucket exists.
    """
    try:
        s3_resource.meta.client.head_bucket(Bucket=bucket_name)
    except ClientError as ce:
        error_code = ce.response['Error']['Code']
        if error_code == ERROR_CODE:
            return False
    return True