aws lambda create-function –function-name ProcessKinesisRecords
–zip-file fileb://function.zip –handler index.handler –runtime nodejs18.x
–role arn:aws:iam::463517587431:role/lambda-kinesis-role-gavin

input.txt

aws lambda invoke –function-name ProcessKinesisRecords
–cli-binary-format raw-in-base64-out
–payload file://input.txt outputfile.txt

创建 kinesis data stream aws kinesis create-stream –stream-name lambda-stream –shard-count 1

查看 aws kinesis describe-stream –stream-name lambda-stream

lamda 增加 kinesis 消费 aws lambda create-event-source-mapping –function-name ProcessKinesisRecords
–event-source arn:aws:kinesis:eu-north-1:463517587431:stream/lambda-stream
–batch-size 100 –starting-position LATEST

查看 list-event-source-mappings aws lambda list-event-source-mappings –function-name ProcessKinesisRecords
–event-source arn:aws:kinesis:eu-north-1:463517587431:stream/lambda-stream

发送数据 aws kinesis put-record –stream-name lambda-stream –partition-key 1 –cli-binary-format raw-in-base64-out
–data “Hello, this is a test.”

可以在这里查看日志: https://eu-north-1.console.aws.amazon.com/cloudwatch/home?region=eu-north-1#logsV2:log-groups

lambda 读取 kinesis 所需权限

创建 trigger 时出错: Cannot access stream arn:aws-cn:kinesis:cn-northwest-1:690706953114:stream/kinesis_demo. Please ensure the role can perform the GetRecords, GetShardIterator, DescribeStream, ListShards, and ListStreams Actions on your stream in IAM.