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, 2022 in Others by Kichu
• 19,040 points
939 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,230 points
1,211 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, 2022 in Others by Kichu
• 19,040 points
414 views
0 votes
1 answer

How can I convert excel file to pdf using TCPDF?

PHPExcel can only read charts from Excel2007 ...READ MORE

answered Oct 21, 2022 in Others by narikkadan
• 63,600 points
2,174 views
0 votes
1 answer

How do I insert a WebP-image (".jpg") in Excel using VBA?

It's not currently on the list of ...READ MORE

answered Nov 15, 2022 in Others by narikkadan
• 63,600 points
774 views
0 votes
1 answer

How do I get an Excel range using row and column numbers in VSTO / C#?

Use: int countRows = xlWorkSheetData.UsedRange.Rows.Count; int countColumns = xlWorkSheetData.UsedRange.Columns.Count; object[,] ...READ MORE

answered Nov 17, 2022 in Others by narikkadan
• 63,600 points
1,802 views
0 votes
1 answer

Excel - How do I make rows that contain row headers into two columns

You can use this formula: =LET(values,B1:E2, headers,MAP(values,LAMBDA(v,INDEX(A1:A2,ROW(v)))), HSTACK(TOCOL(headers),TOCOL(values))) Via MAP the row headers ...READ MORE

answered Jan 26, 2023 in Others by narikkadan
• 63,600 points
739 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,820 points
2,885 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,020 points
6,015 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,020 points
5,234 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP