AWS Lambda getting timeout when trying to delete from Dynamodb

I have table in dynamodb and want to delete data from it using lambda function. Code which I am trying giving timeout error ““errorMessage”: “2020-02-10T11:07:35.954Z 7a400272-8540-444d-a502-ba3a41ad5c05 Task timed out after 3.00 seconds””

Below is the code I am using in Node.js. Not sure what I am doing wrong here. Can any one help?

exports.handler = async (event) => {

var AWS = require(“aws-sdk”);

AWS.config.update({region: “ap-south-1”, endpoint: “https://dynamodb.ap-south-1.amazonaws.com”});

var docClient = new AWS.DynamoDB.DocumentClient();

var table = “NewTable”;

var EmpName = “Saurabh”;

var params = {
TableName:table,
Key:{
“Emp_Name”: EmpName,
}
};

console.log(“Attempting a conditional delete…”);
docClient.delete(params, function(err, data) {
if (err) {
console.error(“Unable to delete item. Error JSON:”, JSON.stringify(err, null, 2));
} else {
console.log(“DeleteItem succeeded:”, JSON.stringify(data, null, 2));
}
});

};

I think your code looks okay. (documentClient.delete)

Perhaps you want to…

  • Increase your lambda timeout to 30s
  • Increase your lambda memory to 1024MB

What do you see in cloudwatch log