Last active
November 22, 2016 09:36
-
-
Save satour/8b628f5f02dc7aa493043cafef712d3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //AWS Lambda function | |
| //required environment variables:["tableName"] | |
| 'use strict'; | |
| console.log('Loading function'); | |
| const doc = require('dynamodb-doc'); | |
| const dynamo = new doc.DynamoDB(); | |
| exports.handler = (event, context, callback) => { | |
| console.log('Received event:', JSON.stringify(event, null, 2)); | |
| const done = (err, res) => callback(null, { | |
| statusCode: err ? '400' : '200', | |
| body: err ? err.message : JSON.stringify(res), | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| }); | |
| var DynamoRequest = { | |
| "TableName": process.env.tableName, | |
| "Item" : { | |
| "timestamp": new Date().getTime(), | |
| "payload": JSON.stringify(event.body) | |
| } | |
| }; | |
| dynamo.putItem(DynamoRequest, done); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment