Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB();
exports.handler = function(event, context) {
console.log("Request received:\n", JSON.stringify(event));
console.log("Context received:\n", JSON.stringify(context));
var tableName = "CommonDynamoDBTable";
var datetime = new Date().getTime().toString();
payload = event;
"TableName": tableName,
"Item" : {
"device_id": {"S": payload.device_id },
"time": {"N": JSON.stringify(datetime) },
"device": {"S": payload.device },
"source": {"S": "from lambda" }
}, function(err, data) {
if (err) {'ERROR: Putting item into dynamodb failed: '+err);
else {
console.log('great success: '+JSON.stringify(data, null, ' '));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.