How to Send Data to Kinesis Firehouse in Python?

The following example code shows how to send data to Amazon Kinesis Firehouse in Python:


import boto3
import json

firehouse_client = boto3.client('firehose')

def send_firehose(data):
    try:
        record = {"Data": json.dumps(data)}
        response = firehouse_client.put_record(
            DeliveryStreamName='my-firehose-stream-name',
            Record=record)
        print('Response from firehouse = ', response)
    except Exception as ex:
        print("Error :",ex)

#Sending data to firehouse
data = [{"name":"abc","id":"1"},{"name":"efg","id":"2"}]    
send_firehose(data)