Git Product home page Git Product logo

multi-region-data-replication's Introduction

multi-region-data-replication

This is a serverless solution for multi-regio data replication that can help store consistent data across different regions. image

The terraform template deploys a Lambda function, two DynamoDB in different regions, and the minimum IAM resources required to run the application.

When items are written or updated or deleted in the table in first region (e.g. us-east-1), the changes are sent to a stream. This pattern configures a Lambda function to poll this stream. When the function is invoked, it retrieves data from the payload containing the contents of the table item that has been written or updated or deleted in the table in the first region, then it makes changes in the table of the second region (e.g. us-west-2) based on the event type.

Requirements

  • Create an AWS account if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
  • AWS CLI installed and configured
  • Git Installed
  • Terraform CLI installed and configured

Deployment Instructions

  1. Create a new directory, navigate to that directory, and clone the repository.

    git clone [email protected]:saiaunghlyanhtet/multi-region-data-replication.git
    
  2. Change directory to the project directory.

    cd multi-region-data-replication
    
  3. Build the Java Lambda Function jar file using Maven.

    mvn clean package
    
  4. From the command line, initialize terraform to to download and install the providers defined in the configuration.

    terraform init
    
  5. From the command line, plan the resouces in the configuration.

    terraform plan -out plan.tfplan
    
  6. From the command line, apply the configuration.

    terraform apply plan.tfplan
    
  7. During the prompts:

    • Enter yes

How it works

When items are written or updated or deleted in the table in first region (e.g. us-east-1), the changes are sent to a stream. This pattern configures a Lambda function to poll this stream. When the function is invoked, it retrieves data from the payload containing the contents of the table item that has been written or updated or deleted in the table in the first region, then it makes changes in the table of the second region (e.g. us-west-2) based on the event type.

Testing

Everytime after having made changes in the table in the first region, those changes will be reflected in the table of the second region. You can also see the detailed logs in the cloudwatch log group for the lambda function.

Clean Up

  1. Delete all deployed resouces.

    terraform destroy
    
  2. During the prompts

    • Enter yes
  3. Confirm all created resources are deleted.

    terraform show
    

multi-region-data-replication's People

Contributors

saiaunghlyanhtet avatar

Watchers

 avatar

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.