def ensure_s3_bucket(s3_client, bucket_name, bucket_region):
    """Ensure an s3 bucket exists, if it does not then create it.

    Args:
        s3_client (:class:`botocore.client.Client`): An s3 client used to
            verify and create the bucket.
        bucket_name (str): The bucket being checked/created.
        bucket_region (str, optional): The region to create the bucket in. If
            not provided, will be determined by s3_client's region.
    """
    try:
        s3_client.head_bucket(Bucket=bucket_name)
    except botocore.exceptions.ClientError as e:
        if e.response['Error']['Message'] == "Not Found":
            logger.debug("Creating bucket %s.", bucket_name)
            create_args = {"Bucket": bucket_name}
            location_constraint = s3_bucket_location_constraint(
                bucket_region
            )
            if location_constraint:
                create_args["CreateBucketConfiguration"] = {
                    "LocationConstraint": location_constraint
                }
            s3_client.create_bucket(**create_args)
        elif e.response['Error']['Message'] == "Forbidden":
            logger.exception("Access denied for bucket %s.  Did " +
                             "you remember to use a globally unique name?",
                             bucket_name)
            raise
        else:
            logger.exception("Error creating bucket %s. Error %s",
                             bucket_name, e.response)
            raise
Ensure an s3 bucket exists, if it does not then create it.

    Args:
        s3_client (:class:`botocore.client.Client`): An s3 client used to
            verify and create the bucket.
        bucket_name (str): The bucket being checked/created.
        bucket_region (str, optional): The region to create the bucket in. If
            not provided, will be determined by s3_client's region.