Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion localstack-core/localstack/services/dynamodb/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we could do table_description["Replicas"] = replica_description_list instead, but it was that way before so let's keep it, only a nit anyway 😄


# update only TableId and SSEDescription if present
if table_definitions := store.table_definitions.get(table_name):
Expand Down
3 changes: 2 additions & 1 deletion localstack-core/localstack/services/dynamodb/v2/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 4 additions & 6 deletions tests/aws/services/dynamodb/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions tests/aws/services/dynamodb/test_dynamodb.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:<partition>:kms:<region>:111111111111:key/<uuid:1>",
"SSEType": "KMS",
"Status": "ENABLED"
},
"KMSDescription": {
"describe_kms_key": {
"KeyMetadata": {
"AWSAccountId": "111111111111",
"Arn": "arn:<partition>:kms:<region>:111111111111:key/<uuid:1>",
Expand All @@ -1450,7 +1450,7 @@
"HTTPStatusCode": 200
}
},
"update-table-unchanged-sse-spec": {
"update_table_sse_description": {
"KMSMasterKeyArn": "arn:<partition>:kms:<region>:111111111111:key/<uuid:1>",
"SSEType": "KMS",
"Status": "ENABLED"
Expand Down
2 changes: 1 addition & 1 deletion tests/aws/services/dynamodb/test_dynamodb.validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading