import json
import boto3
def lambda_handler(event, context):
stream_name = "test" # Streams 이름
# Boto3 Kinesis 클라이언트를 생성합니다.
kinesis_client = boto3.client("kinesis")
# 전달할 레코드 데이터를 생성합니다.
for i in range(1000):
record_data = {
"data": "data"
}
record_data_json = json.dumps(record_data)
response = kinesis_client.put_record(
StreamName=stream_name,
Data=record_data_json,
PartitionKey="1",
)
if response["ResponseMetadata"]["HTTPStatusCode"] == 200:
print(f"{i} Record sent successfully to {stream_name}")
else:
print(f"{i} Failed to send record to {stream_name}")
return {"statusCode": 200, "body": json.dumps("Record sent to Kinesis stream")}