I am creating a simple API and i want to create a function that stores the input data, however i consistently get the Runtime.HandlerNotFound error.
I've checked the environment name (index.js) matches the handler (index.handler)
const AWS = require('aws-sdk');
const dynamodb = new AWS.DynamoDB({region: 'us-east-2', apiVersion: '2012-08-10'});
exports.fn = (event, context, callback) => {
const params = {
Item: {
"UserId": {
N: event.userId
},
"firstname": {
S: event.firstname
},
"lastname": {
S: event.lastname
},
"email": {
S: event.email
}
},
TableName: "contact-info"
};
dynamodb.putItem(params, function(err, data) {
if (err) {
console.log(err);
callback(err);
} else {
console.log(data);
callback(null, data);
}
});
};
I am expecting the AWS Lambda test to return an empty object with no errors.
In index.handler, the index refers to the entry-point file name and handler refers to the function name in the entry-point file which would be invoked by the Lambda.
The reason why you are getting Runtime.HandlerNotFound is because the Lambda is looking for a function called handler in your index.js but you are exporting fn.
Change it to exports.handler=...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With