Skip to content

Instantly share code, notes, and snippets.

@beabetterdevv
Created November 21, 2022 00:31
Show Gist options
  • Save beabetterdevv/5c72deac69f75b229ba71396d18d0e11 to your computer and use it in GitHub Desktop.
Save beabetterdevv/5c72deac69f75b229ba71396d18d0e11 to your computer and use it in GitHub Desktop.
import json
import boto3
kinesis = boto3.client('kinesis')
def lambda_handler(event, context):
# PutRecord API Example
# ---------------------
# Input
record1 = {"personId": 1}
# API Call
response = kinesis.put_record(
StreamName="TestStream", # - name of your kinesis data stream
Data=json.dumps(record1), # - byte string input
PartitionKey="1") # - used as input to hash function to determine which shard to put the record onto
# optional - ExplicitHashKey='string', - ensures the record you are writing lands on a specific shard
# optional - SequenceNumberForOrdering='string' - ensures records written serially are processed in order
# documentation - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kinesis.html#Kinesis.Client.put_record
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment