Data migration module for migrating dynamodb tables to mongodb db collections
npm install dynamodb-mongodb-migrate
const MigrationJob = require('dynamodb-mongodb-migrate');
let sourceConnectionOptions = {
region: <AWS_REGION>,
accessKeyId: <AWS_ACCESS_KEY_ID>,
secretAccessKey: <AWS_SECRET_ACCESS_KEY>
};
let targetConnectionOptions = {
host: <MONGODB_ENDPOINT>,
user: <MONGODB_USERNAME>,
password: <MONGODB_PASSWORD>
};
const migrationJob = new MigrationJob('DYNAMODB_TABLE_NAME', 'MONGODB_COLLECTION_NAME', 'MONGODB_DATABASE_NAME', sourceConnectionOptions, targetConnectionOptions, DYNAMODB_SCAN_LIMIT, DYNAMODB_READ_THROUGHPUT);
migrationJob.run()
const MigrationJob = require('dynamodb-mongodb-migrate');
let sourceConnectionOptions = {
region: <AWS_REGION>,
accessKeyId: <AWS_ACCESS_KEY_ID>,
secretAccessKey: <AWS_SECRET_ACCESS_KEY>
};
let targetConnectionOptions = {
host: <MONGODB_ENDPOINT>,
user: <MONGODB_USERNAME>,
password: <MONGODB_PASSWORD>
};
const migrationJob = new MigrationJob('DYNAMODB_TABLE_NAME', 'MONGODB_COLLECTION_NAME', 'MONGODB_DATABASE_NAME', sourceConnectionOptions, targetConnectionOptions, DYNAMODB_SCAN_LIMIT, DYNAMODB_READ_THROUGHPUT);
const filterExpression = '#attr1 = :val1';
const expressionAttributeNames = {
'#attr1':'attribute1'
};
const expressionAttributeValues = {
':val1':'value1'
}
migrationJob.setSourcefilterExpression(filterExpression, expressionAttributeNames, expressionAttributeValues);
const filterFunction = (item) =>{
return item.attr1 !== null;
}
migrationJob.setFilterFunction(metadata.filterFunction);
const mapperFunction = (item) =>{
return {
mappedAttr1 : item.attr1,
mappedAttr2 : item.attr2
}
}
migrationJob.setMapperFunction(mapperFunction);
migrationJob.run()
npm test