@1auth/store-dynamodb

AWS DynamoDB storage implementation for serverless persistence.

Install

npm i @1auth/store-dynamodb

Peer dependencies

npm i @aws-sdk/client-dynamodb @aws-sdk/util-dynamodb

Usage

import * as store from '@1auth/store-dynamodb'

store.default({
  timeToLiveExpireOffset: 10 * 24 * 60 * 60 // 10 days
})

Configuration options

OptionTypeDefaultDescription
clientDynamoDBClientauto-createdCustom DynamoDB client
timeToLiveExpireOffsetnumber864000TTL offset in seconds
timeToLiveKeystring"remove"DynamoDB TTL attribute name
randomIdobjectID generation options

API

Implements the store interface using DynamoDB operations:

  • existsGetItem with projection
  • countQuery with Select: 'COUNT'
  • selectGetItem or Query
  • selectListQuery
  • insertPutItem
  • updateUpdateItem
  • removeDeleteItem

IAM permissions

{
  "Effect": "Allow",
  "Action": [
    "dynamodb:GetItem",
    "dynamodb:PutItem",
    "dynamodb:UpdateItem",
    "dynamodb:DeleteItem",
    "dynamodb:Query",
    "dynamodb:BatchWriteItem"
  ],
  "Resource": "arn:aws:dynamodb:*:*:table/1auth-*"
}