Skip to content

Instantly share code, notes, and snippets.

@nivertech
Forked from paulspringett/lambda-signup.js
Last active September 11, 2015 10:44
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 nivertech/ce02f16e2631168dbc90 to your computer and use it in GitHub Desktop.
Save nivertech/ce02f16e2631168dbc90 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