Skip to content

Instantly share code, notes, and snippets.

@wenheqi
Created July 23, 2020 06:15
Show Gist options
  • Save wenheqi/0081e1637c74ccec2f631b8f50176d73 to your computer and use it in GitHub Desktop.
Save wenheqi/0081e1637c74ccec2f631b8f50176d73 to your computer and use it in GitHub Desktop.
Connect DynamoDB from Lambda function
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