Skip to content

Instantly share code, notes, and snippets.

@paulspringett
Created September 7, 2015 08:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paulspringett/ec6d3df65e977342d6ea to your computer and use it in GitHub Desktop.
Save paulspringett/ec6d3df65e977342d6ea to your computer and use it in GitHub Desktop.
var aws = require('aws-sdk');
var db = new aws.DynamoDB();
exports.handler = function(signup, context) {
console.log('Received signup:', JSON.stringify(signup, null, 2));
var query = {
TableName: 'Signups',
Item: {
Id: { 'S': signup.id },
EmailAddress: { 'S': signup.email_address },
CreatedAt: { 'S': new Date().toISOString() }
}
};
db.putItem(query, function (err, data) {
if (err) {
console.log(JSON.stringify(err, null, 2));
context.fail('Error with putItem');
} else {
context.succeed({ success: true });
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment