npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dynamo-replicator

v1.0.2

Published

Lambda-ready npm package for replicating DynamoDB tables within or between regions.

Downloads

7

Readme

DynamoDB Replicator

Lambda-ready npm package for replicating DynamoDB tables within or between regions.

Supports one-way replication (single master to slave(s))

Usage

Prerequisites

You'll need NodeJS and NPM installed on your local machine.

Prepare your DynamoDB table

Add a stream to the DynamoDB table you want to use as your master.

  1. In the Overview tab of the DynamoDB table in the AWS console click Manage Stream.
  2. In the overlay that pops up choose New Image (although New and old images should also work should you need that for other reasons).
  3. Click Enable.

Alternatively, if you want to provision your DynamoDB table with CloudFormation add the StreamSpecification property to the AWS::DynamoDB::Table object, e.g.

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Resources": {
    "myTable": {
      "TableName": "mytable",
      "StreamSpecification": {
        "StreamViewType": "NEW_IMAGE"
      }
    }
  }
}

Create the replication Lambda function

  1. Create a new empty directory on your computer
  2. Within that folder create two files, one called package.json and another called index.js.
  3. Edit package.json and save {} as the contents of that file.
  4. In your terminal type npm install --save dynamo-replicator es6-promise
  5. Edit index.js and save the contents of the file shown below (changing SLAVE-REGION and SLAVE-TABLE to be the region and table name of the DynamoDB to be replicated to).
  6. zip the contents of the folder up.
  7. Create a new Lambda function with a role that has sufficient IAM permissions (as a minimum it needs dynamodb::PutItem and dynamodb::DeleteItem on the slave table.
  8. On the Triggers tab of your master DynamoDB, click Create Trigger and New Function; for the Configure event source options, ensure the DynamoDB table is your master table and leave everything else as default and click Next; for the Configure function options name your function something like dynamodb-replicator and for Code entry type select Upload a .ZIP file and choose the zip file created earlier.
  9. Repeat the previous step for multiple slaves changing SLAVE-REGION and SLAVE-TABLE in index.js each time and re-zipping for each slave.
  10. Test by creating and deleting items from the master table and ensuring that the slaves update accordingly.

Contents of index.json:

'use strict';

require('es6-promise').polyfill();

var replicator = require('dynamo-replicator')({
	region: 'SLAVE-REGION',
	table: 'SLAVE-TABLE'
});

exports.handler = function(event, context) {
	replicator.process(event)
		.then(function() {
			context.succeed('success');
		})
		.catch(function(err) {
			context.fail(err);
		});
};