GithubHelp home page GithubHelp logo

dynamodb-globaltables's Introduction

DynamoDB Global Tables Demostration

Step 1

Create a new DynamoDB table named cloudacademy-courses.

aws dynamodb create-table \
    --region us-west-2 \
    --table-name cloudacademy-courses \
    --key-schema AttributeName=courseid,KeyType=HASH \
    --attribute-definitions AttributeName=courseid,AttributeType=S \
    --billing-mode PAY_PER_REQUEST

Step 2

Load course data into the cloudacademy-courses table.

aws dynamodb batch-write-item --region us-west-2 --request-items file://./batch.course.data1.json

Step 3

Update the cloudacademy-courses table and make it a global table with a new replica in the ap-southeast-2 (Sydney) region.

aws dynamodb update-table \
    --region us-west-2 \
    --table-name cloudacademy-courses --cli-input-json  \
'{
  "ReplicaUpdates":
  [
    {
      "Create": {
        "RegionName": "ap-southeast-2"
      }
    }
  ]
}'

Step 4

Check to see if the cloudacademy-courses global table is ready in the ap-southeast-2 region.

Note: Wait 1-2 minutes before running this command to give the previous command enough time to propagate the table updates across to the new region.

aws dynamodb describe-table \
    --region ap-southeast-2 \
    --table-name cloudacademy-courses

Step 5

Setup 30 second watch on the cloudacademy-courses global table deployed in the ap-southeast-2 region - and query the TableStatus attribute. Wait for it to reach Active status.

Note: This command leverages the jq utility to query the json data response for the TableStatus attribute

watch -n 30 "aws dynamodb describe-table \
    --region ap-southeast-2 \
    --table-name cloudacademy-courses \
    | jq -r .Table.TableStatus"

Step 6

Start up tmux and split the terminal.

Pane 1: Run the following command to query for a new record which we will load in the second tmux pane.

watch -n1 "aws dynamodb get-item --region ap-southeast-2 --table-name cloudacademy-courses --key '{\"courseid\" : {\"S\" : \"6666666\"}}'"

Pane 2: Load the new data set into the cloudacademy-courses. Observe how long it takes before the results show up in the other tmux pane.

aws dynamodb batch-write-item --region us-west-2 --request-items file://./batch.course.data2.json

dynamodb-globaltables's People

Contributors

jeremycook123 avatar

Watchers

James Cloos 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.