diff --git a/localstack-core/localstack/services/dynamodb/provider.py b/localstack-core/localstack/services/dynamodb/provider.py index 72fcfbce03519..abaf252c5170d 100644 --- a/localstack-core/localstack/services/dynamodb/provider.py +++ b/localstack-core/localstack/services/dynamodb/provider.py @@ -752,7 +752,8 @@ def describe_table( if replica_region != context.region: replica_description_list.append(replica_description) - table_description.update({"Replicas": replica_description_list}) + if replica_description_list: + table_description.update({"Replicas": replica_description_list}) # update only TableId and SSEDescription if present if table_definitions := store.table_definitions.get(table_name): diff --git a/localstack-core/localstack/services/dynamodb/v2/provider.py b/localstack-core/localstack/services/dynamodb/v2/provider.py index c264febc672c5..149569ad07a28 100644 --- a/localstack-core/localstack/services/dynamodb/v2/provider.py +++ b/localstack-core/localstack/services/dynamodb/v2/provider.py @@ -590,7 +590,8 @@ def describe_table( if replica_region != context.region: replica_description_list.append(replica_description) - table_description.update({"Replicas": replica_description_list}) + if replica_description_list: + table_description.update({"Replicas": replica_description_list}) # update only TableId and SSEDescription if present if table_definitions := store.table_definitions.get(table_name): diff --git a/tests/aws/services/dynamodb/test_dynamodb.py b/tests/aws/services/dynamodb/test_dynamodb.py index 6bc47a51d4907..de2258a4c4305 100644 --- a/tests/aws/services/dynamodb/test_dynamodb.py +++ b/tests/aws/services/dynamodb/test_dynamodb.py @@ -1099,7 +1099,7 @@ def test_global_tables_version_2019( TableName=table_name, ReplicaUpdates=[{"Delete": {"RegionName": "us-east-1"}}] ) response = dynamodb_ap_south_1.describe_table(TableName=table_name) - assert len(response["Table"]["Replicas"]) == 0 + assert "Replicas" not in response["Table"] @markers.aws.only_localstack def test_global_tables(self, aws_client, ddb_test_table): @@ -1669,18 +1669,16 @@ def test_dynamodb_update_table_without_sse_specification_change( SSESpecification=sse_specification, Tags=TEST_DDB_TAGS, ) - snapshot.match("SSEDescription", result["TableDescription"]["SSEDescription"]) + snapshot.match("create_table_sse_description", result["TableDescription"]["SSEDescription"]) kms_master_key_arn = result["TableDescription"]["SSEDescription"]["KMSMasterKeyArn"] result = aws_client.kms.describe_key(KeyId=kms_master_key_arn) - snapshot.match("KMSDescription", result) + snapshot.match("describe_kms_key", result) result = aws_client.dynamodb.update_table( TableName=table_name, BillingMode="PAY_PER_REQUEST" ) - snapshot.match( - "update-table-unchanged-sse-spec", result["TableDescription"]["SSEDescription"] - ) + snapshot.match("update_table_sse_description", result["TableDescription"]["SSEDescription"]) # Verify that SSEDescription exists and remains unchanged after update_table assert result["TableDescription"]["SSEDescription"]["Status"] == "ENABLED" diff --git a/tests/aws/services/dynamodb/test_dynamodb.snapshot.json b/tests/aws/services/dynamodb/test_dynamodb.snapshot.json index 04796e5e5ac11..dc9f00c2c6392 100644 --- a/tests/aws/services/dynamodb/test_dynamodb.snapshot.json +++ b/tests/aws/services/dynamodb/test_dynamodb.snapshot.json @@ -1419,14 +1419,14 @@ } }, "tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_update_table_without_sse_specification_change": { - "recorded-date": "09-12-2024, 16:09:53", + "recorded-date": "17-12-2024, 10:40:03", "recorded-content": { - "SSEDescription": { + "create_table_sse_description": { "KMSMasterKeyArn": "arn::kms::111111111111:key/", "SSEType": "KMS", "Status": "ENABLED" }, - "KMSDescription": { + "describe_kms_key": { "KeyMetadata": { "AWSAccountId": "111111111111", "Arn": "arn::kms::111111111111:key/", @@ -1450,7 +1450,7 @@ "HTTPStatusCode": 200 } }, - "update-table-unchanged-sse-spec": { + "update_table_sse_description": { "KMSMasterKeyArn": "arn::kms::111111111111:key/", "SSEType": "KMS", "Status": "ENABLED" diff --git a/tests/aws/services/dynamodb/test_dynamodb.validation.json b/tests/aws/services/dynamodb/test_dynamodb.validation.json index 423483aefc2e2..1cd5e390bc0f9 100644 --- a/tests/aws/services/dynamodb/test_dynamodb.validation.json +++ b/tests/aws/services/dynamodb/test_dynamodb.validation.json @@ -54,7 +54,7 @@ "last_validated_date": "2023-10-22T20:27:28+00:00" }, "tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_update_table_without_sse_specification_change": { - "last_validated_date": "2024-12-09T16:09:21+00:00" + "last_validated_date": "2024-12-17T10:39:19+00:00" }, "tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_empty_and_binary_values": { "last_validated_date": "2023-08-23T14:32:29+00:00"