Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pythoncode/ddb_sync_test2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import boto3

def syncTables(event, context):
source_ddb = boto3.client('dynamodb', 'us-east-1')
destination_ddb = boto3.client('dynamodb', 'us-west-2')
sync_ddb_table(source_ddb, destination_ddb)

# Scan returns paginated results, so only partial data will be copied
def sync_ddb_table(source_ddb, destination_ddb):
response = source_ddb.scan(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

The API method scan returns paginated results instead of all results. Consider using the pagination API or checking one of the following keys in the response to verify that all results were returned: ExclusiveStartKey, IsTruncated, LastEvaluatedKey, NextToken.

Learn more

TableName="table1"
)

for item in response['Items']:
destination_ddb.put_item(
TableName="table2",
Item=item
)