Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample code to put record to kinesis firehose
import boto3
import json
client = boto3.client('firehose', aws_access_key_id='aaa', aws_secret_access_key='bbb', region_name='eu-west-1')
payload1 = json.dumps({
'id': 111,
'name': 'QiQi',
'email': 'test@test.com'
})
response1 = client.put_record(
DeliveryStreamName='tv-stream-test',
Record={'Data': payload1 + '\n'}
)
print(response1)
###### Put Records in Batch ######
payload2 = json.dumps({
'id': 222,
'name': 'Hello',
'email': 'hello@world.com'
})
payload3 = json.dumps({
'id': 333,
'name': 'tv',
'email': 'tv@data.com'
})
response2 = client.put_record_batch(
DeliveryStreamName='tv-stream-test',
Records=[{'Data': payload2 + '\n'}, {'Data': payload3 + '\n'}]
)
print(response2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.