I am a lambda in aws python boto3. I configured this lambda (a trigger) to read from a specific kinesis stream. It has to read the stream name from the event object. I don't know how to get the stream name. I don't want to hard code the Kinesis stream name in the code. I want to read it from event.
import boto3
import json
from pprint import pprint
s3 = boto3.client('s3')
kinesis = boto3.client('kinesis')
def lambda_handler(event, context):
if event:
for i in event["Records"]:
print(i)
CodePudding user response:
You can see an example Kinesis record event at Using AWS Lambda with Amazon Kinesis.
Each record contains an eventSourceARN
. To print the ARN of each event record:
def lambda_handler(event, context):
for record in event["Records"]:
print(record["eventSourceARN"])
You can infer the Kinesis stream name, if needed, from the ARN.