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

已提問 1 年前檢視次數 398 次
3 個答案
3
已接受的答案

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
專家
已回答 1 年前
profile pictureAWS
專家
已審閱 1 年前
  • 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
專家
已回答 1 年前
  • 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..

已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南