Sends a list of events to a Firehose delivery stream.

def send_to_delivery_stream(events, stream_name):
    """Sends a list of events to a Firehose delivery stream."""
    if not events:
        logger.info("No events provided: nothing delivered to Firehose")
        return

    records = []
    for event in events:
        if not isinstance(event, str):
            # csv events already have a newline
            event = json.dumps(event) + "\n"
        records.append({"Data": event})
    firehose = boto3.client("firehose")
    logger.info("Delivering %s records to Firehose stream '%s'",
                len(records), stream_name)
    resp = firehose.put_record_batch(
        DeliveryStreamName=stream_name,
        Records=records)
    return resp