I have lambda function like below
// Loads in the AWS SDK
const AWS = require('aws-sdk');
// Creates the document client specifing the region
const ddb = new AWS.DynamoDB.DocumentClient({region: 'us-east-1'});
exports.handler = async (event, context, callback) => {
// Handle promise fulfilled/rejected states
await readMessage().then(data => {
data.Items.forEach(function(item) {
console.log(item.message)
});
callback(null, {
// If success return 200, and items
statusCode: 200,
body: data.Items,
headers: {
'Access-Control-Allow-Origin': '*',
},
})
}).catch((err) => {
// If an error occurs write to the console
console.error(err);
})
};
// Function readMessage
// Reads 10 messages from the DynamoDb table Message
// Returns promise
function readMessage() {
const params = {
TableName: 'Message',
Limit: 10
}
return ddb.scan(params).promise();
}
my dynamo db is in region us-east-1 , but above code is not running , it is just timing out.But i am able to run simple hello world inside handler function , and it just works fine.
I have enabled VPC with 6 subnets.. also disabled VPC , not matter what it is timing out without any error logs.. I even increased timeout to 5 mins , it did not do anything.Should I install aws-sdk or something ? Sorry I am completely new to lambda.