enGMzizo / copy-dynamodb-table

Copy Dynamodb table to another in the same or different zone , It is 100% safe. Speed depends on your destination table user-defined write provisioned throughput
130 stars 39 forks source link

How to copy to/from local dynamodb #16

Closed cdelgadob closed 4 years ago

cdelgadob commented 5 years ago

Is it possible to use a local dynamodb as a source or target?

all9lives commented 5 years ago

I have the same question, it would be great to be able to use this to copy from AWS to local.

enGMzizo commented 4 years ago

You can copy Dynamodb table from local to AWS and vice versa using the correct config For example I want to copy test_table from AWS to local I would provide the following config you the copy() function in destination config

const sourceAWSConfig = {
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  region: 'us-east-1',
};

var destinationAWSConfig = {
  accessKeyId: 'AKID',
  secretAccessKey: 'SECRET',
  endpoint: "http://localhost:8000", // use the local dynamodb url here
  region: 'us-west-2' 
}

copy({
  source: {
    tableName: 'test_table',
    config: sourceAWSConfig
  },
  destination: {
    config: destinationAWSConfig,
    tableName: 'copy_test_table',
  },
  log: true,
  create: true,
}, function (err, result) {
  if (err) {
    console.log(err);
  }
  console.log(result);
});

Also it supports coping from local db to AWS if you reversed the config in previous example