【发布时间】:2019-07-29 04:10:21
【问题描述】:
我正在尝试在 aws lambda 上使用带有 python3.6 的 putrecord 将数据添加到 Kinesis Firehose 传输流。在流上调用 put record 时,出现以下异常。
调用PutRecord操作时发生错误(ResourceNotFoundException):找不到帐户123456下的Stream MyStream。
我正在执行以下 python 代码以将数据添加到 Stream。
import boto3
import json
def lambda_handler(event, context):
session = boto3.Session(aws_access_key_id=key_id, aws_secret_access_key=access_key)
kinesis_client = session.client('kinesis', region_name='ap-south-1')
records = event['Records']
write_records = list()
count = 0
for record in records:
count += 1
if str(record['eventName']).lower() == 'insert':
rec = record['dynamodb']['Keys']
rec.update(record['dynamodb']['NewImage'])
new_record = dict()
new_record['Data'] = json.dumps(rec).encode()
new_record['PartitionKey'] = 'PartitionKey'+str(count)
# Following Line throws Exception
kinesis_client.put_record(StreamName="MyStream", Data=new_record['Data'], PartitionKey='PartitionKey'+str(count))
elif str(record['eventName']).lower() == 'modify':
pass
write_records = json.dumps(write_records)
print(stream_data)
MyStream 状态为活动,流数据的来源设置为Direct PUT and other sources
【问题讨论】:
标签: aws-lambda python-3.6 boto3 amazon-kinesis-firehose