39
loading...
This website collects cookies to deliver better user experience
arn:aws:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole
. This had everything I needed to get up and running within a few minutes. The Lambda permission is still a tad bit confusing to me. The principal events.amazonaws.com
needs permission to perform the lambda:InvokeFunction
action, which did not make sense to me at first since Kinesis is what triggers the Lambda. At least, that’s what I thought happened behind the scenes.S3DestinationConfiguration
and ExtendedS3DestinationConfiguration
. From what I can tell, the extended destination allows for additional configuration like Lambda processing whereas the normal destination configuration is for simple forwarding to keep it easy. I decided to use ExtendedS3DestinationConfiguration
because I wanted to use the Lambda integration. Integrating the Lambda is done under the ProcessingConfiguration
property of ExtendedS3DestinationConfiguration
, which ends up looking something like the following snippet....
ExtendedS3DestinationConfiguration:
...
ProcessingConfiguration:
Enabled: 'true'
Processors:
- Parameters:
- ParameterName: LambdaArn
ParameterValue: !GetAtt LambdaFunction.Arn
Type: Lambda
- Effect: Allow
Action:
- 'lambda:InvokeFunction'
- 'lambda:GetFunctionConfiguration'
Resource:
- !Sub "${LambdaFunction.Arn}"
{
"attemptsMade": 4,
"arrivalTimestamp": 1622242573374,
"errorCode": "Lambda.InvokeAccessDenied",
"errorMessage": "Access was denied. Ensure that the access policy allows access to the Lambda function.",
"attemptEndingTimestamp": 1622242649990,
"rawData": "eyJ0aWNrZXJfc3ltYm9sIjoiQU1aTiIsInNlY3RvciI6IlRFQ0hOT0xPR1kiLCJjaGFuZ2UiOi02LjU1LCJwcmljZSI6NzMzLjQxfQ==",
"lambdaArn": "REDACTED"
}
Resource
for the IAM Role’s policy document. What finally did the trick for me was the following adjustment on that previous statement.- Effect: Allow
Action:
- 'lambda:InvokeFunction'
- 'lambda:GetFunctionConfiguration'
Resource:
- !Sub "${LambdaFunction.Arn}*" # NOTE: there is an * after the Lambda's ARN
*
after the Lambda’s ARN. After that, all of my records started flowing through the data pipeline!exports.handler = (event, context, callback) => {
/* Process the list of records and transform them */
const output = event.records.map((record) => {
const plaintextData = Buffer.from(record.data, 'base64').toString('ascii');
console.log(plaintextData);
return {
recordId: record.recordId,
result: 'Ok',
data: record.data,
};
});
console.log(`Processing completed. Successful records ${output.length}.`);
callback(null, { records: output });
};
39