import logging


def generate_presigned_url(s3, bucket_name, key, url_expire=900):
    """
    Purpose:
        Return a presigned URL to a file
    Args:
        s3 (S3 Resource Object): S3 Resource Object
        bucket_name (String): Name of bucket in S3 with Object
        key (String): Name of the object in S3
        url_expire (int): Number of seconds for the URL to live
    Returns:
        presigned_url (String): Presigned URL
    """
    logging.info(f"Generating Presigned URL For {bucket_name} - {key}")

    try:
        return s3.meta.client.generate_presigned_url(
            "get_object",
            Params={
                "Bucket": bucket_name,
                "Key": key
            },
            ExpiresIn=url_expire
        )
    except Exception as err:
        logging.exception(f"Exception generating Presigned URL: {err}")
        raise