How do I convert existing AWS DynamoDB Locals Tables into Global Tables using boto3

0 votes

I have two DynamoDB tables in two different regions, with the same name, both streams enabled, both showing Global Table version 2019.11.21, one has data and one is empty. If I give examples, they can be shown below:

  • Region: us-east-1
  • Table name: MyTable
  • Global Table Version: 2019.11.21
  • The table has items: Yes
  • Region: us-east-2
  • Table name: MyTable
  • Global Table Version: 2019.11.21
  • The table has items: No

I used boto3 DynamoDB client.create_global_table() and client.update_global_table() without any success.

#1. Trying to create Global Table

import boto3

client = boto3.client('dynamodb')

response = client.create_global_table(

    GlobalTableName='MyTable',

    ReplicationGroup=[

        {

            'RegionName': 'us-east-1'

        },

    ]

)

Output:

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the CreateGlobalTable operation: One or more parameter values were invalid: Tables must be empty. These tables contain items: [TableReplica{regionName=us-east-1, tableName=MyTable}]

I understand that client.create_global_table() API call only applies to DynamoDB Table version 2017.11.29 which requires the tables to be empty. So, this won't work for me. Ref: here

#2. Trying to update Global Table

import boto3

client = boto3.client('dynamodb')

update_response = client.update_global_table(

    GlobalTableName='MyTable',

    ReplicaUpdates=[

        {

            'Create': {

                'RegionName': 'us-east-1'

            }

        }

    ]

)

Output:

botocore.errorfactory.GlobalTableNotFoundException: An error occurred (GlobalTableNotFoundException) when calling the UpdateGlobalTable operation: Global table not found: Global table with name: 'Mytable' does not exist.

Adding a second region us-east-2 also does not help.

The boto3 documentation version 1.17.66 does not specify anything particular about the DynamoDB table version to which this operation applies. So, I believe this should work for version 2019.11.21, but the Global Table first has to be in place. Ref: here

According to this blog post, a single region existing Local Table with items can be converted to a Global table. The example used in the blog post was using AWS CLI, but mentioned that AWS SDKs also could be used.

So, how can I do this with boto3?

Apr 5 in Others by Kichu
• 16,850 points
24 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer

How do I log into edureka Master and slave Virtual Machine

Hey @Adetayo, If you are asking about ...READ MORE

answered Apr 1, 2020 in Others by Sirajul
• 59,170 points
252 views
0 votes
0 answers

How do I get data storage used on my AWS RDS?

I wish to know how much storage ...READ MORE

Apr 9 in Others by Kichu
• 16,850 points
21 views
0 votes
1 answer

How do I carry out functional testing?

Well, functional testing is pretty simple. it ...READ MORE

answered Feb 18, 2019 in Others by Jobin
170 views
0 votes
1 answer

How do I install Ruby on Rails?

Hi @Anvi, what @Pratibha has mentioned is ...READ MORE

answered Mar 1, 2019 in Others by Abha
• 28,100 points
265 views
0 votes
1 answer

How do I start studying Node.JS to create a restful API?

Node.js is an open source server environment ...READ MORE

answered Jun 11, 2019 in Others by ArchanaNagur
• 2,340 points
419 views
0 votes
1 answer

How do I get a cheap domain name? - web hosting

Many web hosting companies like amazon's lighsail ...READ MORE

answered Oct 28, 2019 in Others by Yesha
311 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,800 points
1,874 views
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 58,060 points
3,184 views
–1 vote
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 58,060 points
3,483 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP