Skip to content

Instantly share code, notes, and snippets.

@TrueGeek
Created January 11, 2019 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TrueGeek/5b8c6a0601a844d72374fdf9be0aa69d to your computer and use it in GitHub Desktop.
Save TrueGeek/5b8c6a0601a844d72374fdf9be0aa69d to your computer and use it in GitHub Desktop.
AWS Lambda DynamoDB PUT
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB.DocumentClient();
exports.handler = (event, context, callback) => {
console.log(JSON.stringify(event));
dynamodb.put({
TableName: 'ggmug',
Item: {
mug: event.mug,
color: event.color,
has_handle: event.has_handle
}
}, (err, data) => {
if (err) {
console.log('Error putting item into dynamodb failed: '+err);
callback('500');
}
else {
console.log('saved');
callback(null, data);
}
});
console.log('done');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment