From e547c6729f11809174e70bc220e8c139cc3f03ba Mon Sep 17 00:00:00 2001 From: Willis Date: Mon, 26 Apr 2021 14:31:10 -0400 Subject: [PATCH] adding ddb --- pythoncode/ddb_sync_test2.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pythoncode/ddb_sync_test2.py diff --git a/pythoncode/ddb_sync_test2.py b/pythoncode/ddb_sync_test2.py new file mode 100644 index 0000000..0f77b38 --- /dev/null +++ b/pythoncode/ddb_sync_test2.py @@ -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( + TableName="table1" + ) + + for item in response['Items']: + destination_ddb.put_item( + TableName="table2", + Item=item + ) \ No newline at end of file