Created
July 23, 2020 06:15
-
-
Save wenheqi/0081e1637c74ccec2f631b8f50176d73 to your computer and use it in GitHub Desktop.
Connect DynamoDB from Lambda function
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
const AWS = require('aws-sdk'); | |
const ddb = new AWS.DynamoDB.DocumentClient(); | |
exports.handler = (event, context, callback) => { | |
const params = { | |
TableName: "TABLE_NAME_HERE", | |
Key: { | |
"KEY_NAME_HERE": "KEY_VALUE_HERE" | |
} | |
} | |
ddb.get(params, (err, data) => { | |
if(err) { | |
return callback(err, null); | |
} | |
return callback(null, data); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment