I am trying to use Lambda as a Kafka consumer, to be triggered once receive a new Kafka message. I got a .yaml template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
my-service
Sample SAM Template for my-service
Globals:
Function:
Timeout: 3
Api:
Cors:
AllowMethods: "'POST, GET, PUT'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"
AllowCredentials: false
Resources:
ProcessMSKfunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: index.handler
Runtime: nodejs12.x
MemorySize: 312
Timeout: 5000
Events:
MSKEvent:
Type: MSK
Properties:
StartingPosition: LATEST
Stream: [...]
Topics:
- MyTopic
Policies:
- AWSLambdaMSKExecutionRole: {}
and this Lambda is executing one sample handler
let response;
exports.handler = async (event) => {
// Iterate through keys
for (let key in event.records) {
console.log('Key: ', key);
// Iterate through records
event.records[key].map((record) => {
console.log('Record: ', record);
// Decode base64
const msg = Buffer.from(record.value, 'base64').toString();
console.log('Message:', msg);
});
}
};
but when I try to build, executing the sam build, it is getting error:
"File "C:... ...site-packages\samtranslator\sdk\resource.py", line 24, in init self.type = resource_dict.get("Type") AttributeError: 'list' object has no attribute 'get'"
Does anyone has a fix alternative for this kind of error?