Skip to content

Commit 05a4ee2

Browse files
Pass only required attributes of LSI's while creating table (#198)
* Pass only required attributes of LSI's while creating table Fixes issues in create_table, when table has local secondary indexes * Apply Black * Apply Black with latest version
1 parent fcd9eb6 commit 05a4ee2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

dynamodump/dynamodump.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,18 @@ def prepare_provisioned_throughput_for_restore(provisioned_throughput):
770770
}
771771

772772

773+
def prepare_lsi_for_restore(lsi):
774+
"""
775+
This function makes sure that the payload returned for the boto3 API call create_table is compatible
776+
See: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.create_table
777+
"""
778+
return {
779+
"IndexName": lsi["IndexName"],
780+
"KeySchema": lsi["KeySchema"],
781+
"Projection": lsi["Projection"],
782+
}
783+
784+
773785
def prepare_gsi_for_restore(gsi):
774786
"""
775787
This function makes sure that the payload returned for the boto3 API call create_table is compatible
@@ -905,7 +917,9 @@ def do_restore(
905917
)
906918

907919
if table_local_secondary_indexes is not None:
908-
optional_args["LocalSecondaryIndexes"] = table_local_secondary_indexes
920+
optional_args["LocalSecondaryIndexes"] = [
921+
prepare_lsi_for_restore(gsi) for gsi in table_local_secondary_indexes
922+
]
909923

910924
if table_global_secondary_indexes is not None:
911925
optional_args["GlobalSecondaryIndexes"] = [

0 commit comments

Comments
 (0)