import logging


def get_bucket_name_from_s3_event(event):
    """
    Purpose:
        Get the S3 Bucket name from an event triggered by the creation
        of an object in S3
    Args:
        event (Dict): Dict with event details from the triggering event
            for the function.
    Return:
        bucket_name (String): Bucket name of the object creation triggering
            the call to the Lambda function
    """

    bucket_name =\
        event.get("Records", {})[0].get("s3", {}).get("bucket", {}).get("name", None)
    if not bucket_name:
        error_msg = "Event did not have a bucket name; cannot process event"
        logging.error(error_msg)
        raise Exception(error_msg)

    return event.get("Records", {})[0].get("s3", {}).get("bucket", {}).get("name", None)