Skip to content

Instantly share code, notes, and snippets.

@Ozerich
Created April 29, 2016 15:33
Show Gist options
  • Save Ozerich/31ea9e6178308fa3b16143c077521ac0 to your computer and use it in GitHub Desktop.
Save Ozerich/31ea9e6178308fa3b16143c077521ac0 to your computer and use it in GitHub Desktop.
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 = "users";
dynamodb.putItem({
"TableName": tableName,
"Item": {
"email": {
"S": '1'
},
"login": {
"S": '2'
},
"count": {
"N": '2'
}
}
}, function(err, data) {
if (err) {
context.fail('ERROR: Dynamo failed: ' + err);
} else {
console.log('Dynamo Success: ' + JSON.stringify(data, null, ' '));
context.succeed('1,2,3,4');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment