import base64
import gzip
import json


def uncompress_payload(cw_event: dict) -> dict:
    """Uncompresses a Cloudwatch log event and turns it into a dict.

    Args:
        cw_event: Dict containing base64 encoded and zipped logs entry
            delivered by Cloudwatch Logs subscription
    Returns:
        (dict): uncompressed logs data
    """
    cw_data = cw_event["awslogs"]["data"]

    compressed_payload = base64.b64decode(cw_data)
    uncompressed_payload = gzip.decompress(compressed_payload)
    return json.loads(uncompressed_payload)