from datetime import datetime


def datetime_to_cloudwatch_ts(dt):
    """
    Convert a Python ``datetime`` instance to a CloudWatch timestamp,
    the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
    """
    epoch = datetime(1970, 1, 1, 0, 0, 0)
    return int((dt - epoch).total_seconds()) * 1000