AWS Credentials

There are three ways to specify AWS credentials:

Dynamoose Object

var dynamoose = require('dynamoose');

dynamoose.model(name, schema, [options])

Compiles a new model or looks up an existing one. options is optional.

Default options:

  create: true, // Create table in DB, if it does not exist,
  update: false, // Update remote indexes if they do not match local index structure
  waitForActive: true, // Wait for table to be created before trying to use it
  waitForActiveTimeout: 180000, // wait 3 minutes for table to activate
  streamOptions: { // sets table stream options
    enabled: false, // sets if stream is enabled on the table
    type: undefined // sets the stream type (NEW_IMAGE | OLD_IMAGE | NEW_AND_OLD_IMAGES | KEYS_ONLY) (
  serverSideEncryption: false // Set SSESpecification.Enabled (server-side encryption) to true or false (default: true)

Basic example:

var Cat = dynamoose.model('Cat', { id: Number, name: String });

streamOptions: object (optional)

Indicates whether stream is enabled or disabled on the table and dictates which type of stream the table should have. This is passed into into the StreamSpecification option property when creating the table.

serverSideEncryption: boolean

Indicates whether server-side encryption is enabled (true) or disabled (false) on the table. This boolean will be passed into the SSESpecification.Enabled option property when creating the table. Currently (when feature was implemented) DynamoDB doesn’t support updating a table to add or remove server-side encryption, therefore this option will only be respected on creation of table, if table already exists in DynamoDB when using Dynamoose this value will be ignored.

var model = dynamoose.model('Cat', {...}, {
	streamOptions: {
      enabled: true,
      type: "NEW_AND_OLD_IMAGES"
	serverSideEncryption: true


Configure dynamoose to use a DynamoDB local for testing.

url defaults to ‘http://localhost:8000’



Configures and returns the AWS.DynamoDB object


AWS object for dynamoose. Used to configure AWS for dynamoose.

  accessKeyId: 'AKID',
  secretAccessKey: 'SECRET',
  region: 'us-east-1'


Sets the default to be used when creating a model. Can be modified on a per model by passing options to .model().

Default options:

  create: true // Create table in DB if it does not exist
  prefix: '', // Default prefix for all DynamoDB tables
  suffix: '' // Default suffix for all DynamoDB tables

It is recommended that create be disabled for production environments.

dynamoose.setDefaults( { create: false });


The dynamoose Schema class, used to create new schema definitions. For example:

var appleSchema = new dynamoose.Schema({
  id: Number, 
  type: String


Table class

AWS X-Ray Support

You can achieve Amazon Web Services X-Ray support using a configuration similar to the following.

var AWSXRay = require('aws-xray-sdk');
var dynamoose = require('dynamoose');
dynamoose.AWS = AWSXRay.captureAWS(require('aws-sdk'));


Sets the document client for DynamoDB. This can be used to integrate with Amazon Web Services DAX.