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
6 changes: 5 additions & 1 deletion localstack-core/localstack/services/dynamodb/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,10 @@ def update_table(

SchemaExtractor.invalidate_table_schema(table_name, context.account_id, global_table_region)

schema = SchemaExtractor.get_table_schema(
table_name, context.account_id, global_table_region
)

# TODO: DDB streams must also be created for replicas
if update_table_input.get("StreamSpecification"):
create_dynamodb_stream(
Expand All @@ -860,7 +864,7 @@ def update_table(
result["TableDescription"].get("LatestStreamLabel"),
)

return result
return UpdateTableOutput(TableDescription=schema["Table"])

def list_tables(
self,
Expand Down
8 changes: 6 additions & 2 deletions localstack-core/localstack/services/dynamodb/v2/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def update_table(
global_table_region = self.get_global_table_region(context, table_name)

try:
result = self._forward_request(context=context, region=global_table_region)
self._forward_request(context=context, region=global_table_region)
except CommonServiceException as exc:
# DynamoDBLocal refuses to update certain table params and raises.
# But we still need to update this info in LocalStack stores
Expand Down Expand Up @@ -689,7 +689,11 @@ def update_table(

SchemaExtractor.invalidate_table_schema(table_name, context.account_id, global_table_region)

return result
schema = SchemaExtractor.get_table_schema(
table_name, context.account_id, global_table_region
)

return UpdateTableOutput(TableDescription=schema["Table"])

def list_tables(
self,
Expand Down
34 changes: 34 additions & 0 deletions tests/aws/services/dynamodb/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,40 @@ def test_dynamodb_create_table_with_partial_sse_specification(
result = aws_client.dynamodb.describe_table(TableName=table_name)
assert "SSESpecification" not in result["Table"]

@markers.aws.validated
def test_dynamodb_update_table_without_sse_specification_change(
self, dynamodb_create_table_with_parameters, snapshot, aws_client
):
table_name = f"test_table_{short_uid()}"

sse_specification = {"Enabled": True}

result = dynamodb_create_table_with_parameters(
TableName=table_name,
KeySchema=[{"AttributeName": PARTITION_KEY, "KeyType": "HASH"}],
AttributeDefinitions=[{"AttributeName": PARTITION_KEY, "AttributeType": "S"}],
ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
SSESpecification=sse_specification,
Tags=TEST_DDB_TAGS,
)
snapshot.match("SSEDescription", 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)

result = aws_client.dynamodb.update_table(
TableName=table_name, BillingMode="PAY_PER_REQUEST"
)
snapshot.match(
"update-table-unchanged-sse-spec", result["TableDescription"]["SSEDescription"]
)

# Verify that SSEDescription exists and remains unchanged after update_table
assert result["TableDescription"]["SSEDescription"]["Status"] == "ENABLED"
assert result["TableDescription"]["SSEDescription"]["SSEType"] == "KMS"
assert result["TableDescription"]["SSEDescription"]["KMSMasterKeyArn"] == kms_master_key_arn

@markers.aws.validated
def test_dynamodb_get_batch_items(
self, dynamodb_create_table_with_parameters, snapshot, aws_client
Expand Down
39 changes: 39 additions & 0 deletions tests/aws/services/dynamodb/test_dynamodb.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -1417,5 +1417,44 @@
]
}
}
},
"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-content": {
"SSEDescription": {
"KMSMasterKeyArn": "arn:<partition>:kms:<region>:111111111111:key/<uuid:1>",
"SSEType": "KMS",
"Status": "ENABLED"
},
"KMSDescription": {
"KeyMetadata": {
"AWSAccountId": "111111111111",
"Arn": "arn:<partition>:kms:<region>:111111111111:key/<uuid:1>",
"CreationDate": "datetime",
"CustomerMasterKeySpec": "SYMMETRIC_DEFAULT",
"Description": "Default key that protects my DynamoDB data when no other key is defined",
"Enabled": true,
"EncryptionAlgorithms": [
"SYMMETRIC_DEFAULT"
],
"KeyId": "<uuid:1>",
"KeyManager": "AWS",
"KeySpec": "SYMMETRIC_DEFAULT",
"KeyState": "Enabled",
"KeyUsage": "ENCRYPT_DECRYPT",
"MultiRegion": false,
"Origin": "AWS_KMS"
},
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
},
"update-table-unchanged-sse-spec": {
"KMSMasterKeyArn": "arn:<partition>:kms:<region>:111111111111:key/<uuid:1>",
"SSEType": "KMS",
"Status": "ENABLED"
}
}
}
}
3 changes: 3 additions & 0 deletions tests/aws/services/dynamodb/test_dynamodb.validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"tests/aws/services/dynamodb/test_dynamodb.py::TestDynamoDB::test_dynamodb_streams_describe_with_exclusive_start_shard_id": {
"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"
},
"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