From e6f8e07525be8b74e391da7fe0991f5fed752f88 Mon Sep 17 00:00:00 2001 From: DilLip Chowdary Rayapati <66238621+DilLip-Chowdary-Codes@users.noreply.github.com> Date: Tue, 14 Feb 2023 11:54:17 +0530 Subject: [PATCH 1/3] Pass only required attributes of LSI's while creating table Fixes issues in create_table, when table has local secondary indexes --- dynamodump/dynamodump.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dynamodump/dynamodump.py b/dynamodump/dynamodump.py index b803ecb8..1054fb3b 100755 --- a/dynamodump/dynamodump.py +++ b/dynamodump/dynamodump.py @@ -770,6 +770,18 @@ def prepare_provisioned_throughput_for_restore(provisioned_throughput): } +def prepare_lsi_for_restore(lsi): + """ + This function makes sure that the payload returned for the boto3 API call create_table is compatible + See: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.create_table + """ + return { + "IndexName": lsi["IndexName"], + "KeySchema": lsi["KeySchema"], + "Projection": lsi["Projection"] + } + + def prepare_gsi_for_restore(gsi): """ This function makes sure that the payload returned for the boto3 API call create_table is compatible @@ -905,7 +917,9 @@ def do_restore( ) if table_local_secondary_indexes is not None: - optional_args["LocalSecondaryIndexes"] = table_local_secondary_indexes + optional_args["LocalSecondaryIndexes"] = [ + prepare_lsi_for_restore(gsi) for gsi in table_local_secondary_indexes + ] if table_global_secondary_indexes is not None: optional_args["GlobalSecondaryIndexes"] = [ From 87da599da1a30623616946f4f0267b35d8358364 Mon Sep 17 00:00:00 2001 From: dillip Date: Sat, 18 Feb 2023 15:52:10 +0530 Subject: [PATCH 2/3] Apply Black --- dynamodump/dynamodump.py | 6 ++---- setup.py | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dynamodump/dynamodump.py b/dynamodump/dynamodump.py index 1054fb3b..ea80ab96 100755 --- a/dynamodump/dynamodump.py +++ b/dynamodump/dynamodump.py @@ -778,7 +778,7 @@ def prepare_lsi_for_restore(lsi): return { "IndexName": lsi["IndexName"], "KeySchema": lsi["KeySchema"], - "Projection": lsi["Projection"] + "Projection": lsi["Projection"], } @@ -1280,9 +1280,7 @@ def main(): sleep_interval = AWS_SLEEP_INTERVAL else: conn = _get_aws_client( - service="dynamodb", - profile=args.profile, - region=args.region, + service="dynamodb", profile=args.profile, region=args.region, ) sleep_interval = AWS_SLEEP_INTERVAL diff --git a/setup.py b/setup.py index 4949792e..6c868dbe 100644 --- a/setup.py +++ b/setup.py @@ -12,9 +12,7 @@ long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/bchew/dynamodump", - project_urls={ - "Releases": "https://github.com/bchew/dynamodump/releases", - }, + project_urls={"Releases": "https://github.com/bchew/dynamodump/releases",}, classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", @@ -22,7 +20,5 @@ packages=["dynamodump"], python_requires=">=3.7", install_requires=["boto3==1.26.41", "six==1.16.0"], - entry_points={ - "console_scripts": ["dynamodump=dynamodump.dynamodump:main"], - }, + entry_points={"console_scripts": ["dynamodump=dynamodump.dynamodump:main"],}, ) From fb56e8de2b1a92527408d0b47cf7dc5b7f77c164 Mon Sep 17 00:00:00 2001 From: dillip Date: Wed, 22 Feb 2023 11:58:55 +0530 Subject: [PATCH 3/3] Apply Black with latest version --- dynamodump/dynamodump.py | 4 +++- setup.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dynamodump/dynamodump.py b/dynamodump/dynamodump.py index ea80ab96..3413ee29 100755 --- a/dynamodump/dynamodump.py +++ b/dynamodump/dynamodump.py @@ -1280,7 +1280,9 @@ def main(): sleep_interval = AWS_SLEEP_INTERVAL else: conn = _get_aws_client( - service="dynamodb", profile=args.profile, region=args.region, + service="dynamodb", + profile=args.profile, + region=args.region, ) sleep_interval = AWS_SLEEP_INTERVAL diff --git a/setup.py b/setup.py index 6c868dbe..4949792e 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,9 @@ long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/bchew/dynamodump", - project_urls={"Releases": "https://github.com/bchew/dynamodump/releases",}, + project_urls={ + "Releases": "https://github.com/bchew/dynamodump/releases", + }, classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", @@ -20,5 +22,7 @@ packages=["dynamodump"], python_requires=">=3.7", install_requires=["boto3==1.26.41", "six==1.16.0"], - entry_points={"console_scripts": ["dynamodump=dynamodump.dynamodump:main"],}, + entry_points={ + "console_scripts": ["dynamodump=dynamodump.dynamodump:main"], + }, )