Skip to content

Conversation

IreneLime
Copy link
Contributor

Motivation

This PR resolves the issue: #11781
Description of issue: The output from the UpdateTable command does not include the SSEDescription for a table which was created with it.

Previous Behaviour

As described by the previous comment on line 781 of localstack-core\localstack\services\dynamodb\provider.py, DynamoDBLocal cannot change certain table parameters, including SSEDescription and replica.
As a result, the return value of update_table is a table returned by DynamoDBLocal, which does not contain these parameters.

Changes

After DynamoDBLocal makes changes to the table, use get_table_schema to retrieve the entire schema definition of the table, which includes the original and changed parameters.
Change return value such that the update_table function returns the schema obtained.

Testing

Create a dynamodb table:
awslocal dynamodb create-table --table-name Example --attribute-definitions AttributeName=key,AttributeType=S --key-schema AttributeName=key,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 --sse-specification Enabled=true,SSEType=KMS,KMSMasterKeyId=some-kms

Update the dynamodb table:
awslocal dynamodb update-table --table-name Example --billing-mode PAY_PER_REQUEST

Original code will not return the original SSEDescription. New changes will include both SSEDescription and the changed "Billing Mode" parameters.

Copy link
Contributor

@localstack-bot localstack-bot left a comment

Choose a reason for hiding this comment

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

Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.

@localstack-bot
Copy link
Contributor

localstack-bot commented Nov 26, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@IreneLime
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

localstack-bot added a commit that referenced this pull request Nov 26, 2024
@IreneLime
Copy link
Contributor Author

I do not have the permission to add labels to the PR. Please add a semver: patch label to this PR. Thanks!

@bentsku bentsku added the semver: patch Non-breaking changes which can be included in patch releases label Nov 27, 2024
@viren-nadkarni
Copy link
Member

Thank you for contributing @IreneLime. Could you please add some tests?

@IreneLime
Copy link
Contributor Author

Hi @viren-nadkarni, I have added an aws service test on dynamodb for this case.
Test added: test_dynamodb_update_table_without_sse_specification_change will create a table with SSESpecification, and update other contents in the table, then check if "SSESpecification" entries still exist in the table.

To run the test: TEST_PATH="tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_update_table_without_sse_specification_change" make test

Without the fix: Test will fail because "SSESpecification" does not exist in returned table content.
With the fix: Test passes with matching "SSESpecification" content.

Copy link
Member

@viren-nadkarni viren-nadkarni left a comment

Choose a reason for hiding this comment

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

Great job adding the test! Just one hiccup:

Copy link
Member

@viren-nadkarni viren-nadkarni left a comment

Choose a reason for hiding this comment

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

Congrats on your first contribution to LocalStack!

@viren-nadkarni viren-nadkarni merged commit e548fb2 into localstack:master Dec 17, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants