Created
March 2, 2021 15:16
-
-
Save tonio-m/f25c186782ce648f1b1a52ed333a48f3 to your computer and use it in GitHub Desktop.
kinesis put get example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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