Unable to connect kinesis trigger to lambda. "Cannot access stream"- IAM role is configured properly. How do I debug this?

Viewed 1227

I am trying to connect a kinesis trigger to a lambda function, but keep getting the same error no matter how I configure the IAM. I've also tried setting the IAM role to "*" in most fields. How can I determine what's preventing the trigger from connecting if the IAM role is configured the way the error has requested?

Here is the error:

There was an error creating the trigger: Cannot access stream [arn]. Please ensure the role can perform the GetRecords, GetShardIterator, DescribeStream, and ListStreams Actions on your stream in IAM.

Here is my IAM role which can perform the GetRecords, GetShardIterator, DescribeStream, and ListStreams PLUS more:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "Stmt1505763107000",
        "Effect": "Allow",
        "Action": [
            "kinesis:CreateStream",
            "kinesis:DescribeStream",
            "kinesis:GetShardIterator",
            "kinesis:GetRecords",
            "kinesis:ListRecords",
            "kinesis:PutRecord",
            "kinesis:PutRecords"
        ],
        "Resource": [
            "arn:aws:kinesis:us-east-2:219021079475:stream/lead"
        ]
    },
    {
        "Sid": "Stmt1505763184000",
        "Effect": "Allow",
        "Action": [
            "cloudwatch:*"
        ],
        "Resource": [
            "*"
        ]
    },
    {
        "Sid": "Stmt1505763256000",
        "Effect": "Allow",
        "Action": [
            "lambda:*"
        ],
        "Resource": [
            "arn:aws:lambda:us-east-2:219021079475:function:logsKinesisData"
        ]
    }
]

}

I've not written the lambda function beyond set up:

'use strict';

console.log('Loading function');

exports.handler = (event, context, callback) => {
//console.log('Received event:', JSON.stringify(event, null, 2));
event.Records.forEach((record) => {
    // Kinesis data is base64 encoded so decode here
    const payload = new Buffer(record.kinesis.data, 'base64').toString('ascii');
    console.log('Decoded payload:', payload);
});
callback(null, `Successfully processed ${event.Records.length} records.`);
};
0 Answers
Related