Skip to content

Instantly share code, notes, and snippets.

@tonio-m
Created March 2, 2021 15:16
Show Gist options
  • Save tonio-m/f25c186782ce648f1b1a52ed333a48f3 to your computer and use it in GitHub Desktop.
Save tonio-m/f25c186782ce648f1b1a52ed333a48f3 to your computer and use it in GitHub Desktop.
kinesis put get example
import boto3
from pprint import pprint
client = boto3.client('kinesis', region_name='us-east-1')
def put():
response = client.put_record(
StreamName='teste',
Data=b'bytes',
PartitionKey='string'
)
pprint(response)
def get():
shards = client.describe_stream(StreamName='teste')['StreamDescription']['Shards']
shard_ids = [s['ShardId'] for s in shards]
shard_iterator = client.get_shard_iterator(
StreamName='teste',
ShardId=shard_ids[0],
ShardIteratorType='LATEST')['ShardIterator']
response = client.get_records(ShardIterator=shard_iterator)
pprint(response)
pprint(len(response['Records']))
if __name__ == '__main__':
put()
get()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment