Git Product home page Git Product logo

dynamodb-table-utils's Introduction

Copy DynamoDB Table

This project is an AWS Lambda to replicate items from a DynamoDB table to another. It uses very simple API calls through the AWS SDK v3 DynamoDB package. It also supports cross-zone in the AWS regions.

Use case

This lambda may be much useful when you want to rename a table or replicate it to another region. However, it is just a lambda to scan all the items from an origin table and write them to a destination one. It does not create a new table, so you will need to create it with the required primary and sort keys before running the lambda.

You can also get the lambda code to use it in your own context - maybe parsing the data before writing it to the destination table. The sky is the limit 😄.

Installation and Usage

This project is running under the amazing Serverless Stack framework. It means you can easily deploy the lambda through your command line and access it on AWS's Lambda console to run and copy the table you want.

The setup is actually pretty simple. You got to:

  • Clone the repo;
  • Install the dependencies;
  • Export the AWS credentials on your CLI;
  • Deploy the app and access it on AWS Lambda's console.
# cloning the repo

git clone [email protected]:carlosdnba/copy-ddb-table.git

# installing the dependencies

cd copy-ddb-table

npm i

# exporting credentials

export AWS_ACCESS_KEY_ID=aws-access-key-id
export AWS_SECRET_ACCESS_KEY=aws-secret-access-key

# deploying the lambda

npm run deploy

After deploying, you'll some outputs on your terminal. You should find the URL of your deployed lambda, like:

✅  carlovsk-copy-ddb-table


Stack carlovsk-copy-ddb-table
  Status: deployed
  Outputs:
    LambdaName: carlovsk-copy-ddb-table-main
    ConsoleUrl: https://console.aws.amazon.com/lambda/home?region=us-east-1#/functions/carlovsk-copy-ddb-table-main?tab=testing

Use the ConsoleUrl to access your deployed lambda and run it. You will need to send a JSON payload like the one below:

{
  "origin":{
    "tableName": "origin-table-name",
    "region": "us-east-1"
  },
  "destination":{
    "tableName": "destination-table-name",
    "region": "sa-east-1"
  }
}

After following all steps, your table items should have been successfully replicated 😄.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.