Programatic way of Creating DynamoDB Global Table

0

When We create a dynamoDB global table by API interface using AWS Golang SDK or using AWS CLI interface it always creates it using dynamoDB 2017 version.. But 2017 version has a limitation of adding new replication region with the already data present in other regions. It mandates tables to be empty.. So we are looking for a programmatic way of creating dynamoDB Global table with 2019 version which doesn't have that problem in 2017 version.. Please do let us know is this supported ? And how to achieve this.. Thank you..

asked a year ago390 views
3 Answers
3
Accepted Answer

To create a V2019 of DynamoDB Global Table, you need to use the CreateTable API and NOT the CreateGlobalTable API.

When DynamoDB moved to v2019 it aligned with the table class, which is why you are seeing the creation of v2017 using the global table class.

Once you create the table, you call UpdateTable and specify the ReplicaUpdates

aws dynamodb create-table \
    --table-name custT \
    --attribute-definitions AttributeName=pk,AttributeType=S AttributeName=sk,AttributeType=S \
    --key-schema AttributeName=pk,KeyType=HASH AttributeName=sk,KeyType=RANGE \
    --billing-mode PAY_PER_REQUEST

aws dynamodb wait table-exists \
    --table-name custT

aws dynamodb update-table \
--table-name custT \
--replica-updates '[{"Create": {"RegionName": "eu-west-2"}}]'
profile pictureAWS
EXPERT
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago
  • Hi Leeroy,

    Thank you so much for the solution. It unblocked me..

    Best Regards Nagappa

  • That's good to hear Nagappa, please feel free to mark the answer as accepted.

  • Accepted Now.. Thank you ..

0

I just created a new table and replicas which are the 2019 version. What version of the SDK and CLI are you using? Which region is the primary DynamoDB table in?

profile pictureAWS
EXPERT
answered a year ago
  • Thank you for the reply.. Did you create through AWS Console ? I am using aws-sdk-go-v2 SDK .. Also you can use aws CLI to create table and to create global table with two replicas .. When i do create createGlobalTable dynamoDB version becomes 2017..

    aws --version aws-cli/2.8.10 Python/3.10.8 Darwin/21.6.0 source/arm64 prompt/off

    github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.7

  • I used the AWS CLI: aws-cli/2.4.18 Python/3.8.8 Darwin/21.6.0 exe/x86_64 prompt/off

    Which regions are you using? I created my primary table in ap-southeast-2 and replicas in us-east-1 and eu-west-1.

0

Thank you for the reply.. Did you create through AWS Console ? I am using aws-sdk-go-v2 SDK .. Also you can use aws CLI to create table and to create global table with two replicas .. When i do create createGlobalTable dynamoDB version becomes 2017..

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions