def write_records()

in cdk/stacks/sample_kinesis_stream_producer/producer_lambda/app.py [0:0]


def write_records(stream_name, records):
    kinesis_records = []
    for record in records:
        kinesis_records.append({
            'Data': json.dumps(record),
            'PartitionKey': record["DeviceID"]
        })

    result = None
    try:
        result = kinesis.put_records(
            StreamName=stream_name,
            Records=kinesis_records, )

        status = result['ResponseMetadata']['HTTPStatusCode']
        print("Processed %d records. WriteRecords Status: %s" %
              (len(records), status))
    except Exception as err:
        print("Error:", err)
        if result is not None:
            print("Result:{}".format(result))