Get item

Last update in 9/2019

Have you just read my previous article about putting data in DynamoDB? And are you wondering how to get that data? You are at the right place. First of all you need to add permission for lambda to get item from DynamoDB.

# ...
# ...
- Effect: Allow
- dynamodb:GetItem
Resource: 'arn:aws:dynamodb:us-east-1:111111111:table/tableName'

After that you should open function handler and import aws-sdk via import or require syntax...

const AWS = require('aws-sdk')
// or if you're using ES6
import AWS from 'aws-sdk'

...and initialize DynamoDB document client.

const docClient = new AWS.DynamoDB.DocumentClient()

And last thing you have to do is initialize params object that will contain DynamoDB table name, your table's primary key and it's value. params object is then passed as argument to document client get method.

const params = {
TableName: tableName,
Key: {
id: 'value',

try {
await docClient.get(params).promise()
} catch (e) {
return console.log(e)

Quite easy when you wrap your head around one of CRUD DynamoDB functions.