Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass only required attributes of LSI's while creating table #198

Merged
merged 3 commits into from
Feb 23, 2023
Merged
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
16 changes: 15 additions & 1 deletion dynamodump/dynamodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"] = [
Expand Down