I'm pretty new to AWS API Gateway, Lambda and DynamoDB, but I did a little bit of research and figured out how to build a simple Lambda function that scans a DynamoDB table.
I think I've successfully scanned the table and in the callback have access to the results within the data variable.
Right now, my function just completes with a Succeeded message, but I can't for the life of me actually figure out how to display the data that it scanned as the response. Any help would be greatly appreciated.
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
var tableName = "MyTableName";
dynamodb.scan({
TableName : tableName
}, function(err, data) {
if (err) {
context.done('error','reading dynamodb failed: '+err);
}
context.succeed('Success');
});
};