Skip to content

Commit 042e4b8

Browse files
author
Lucas McDonald
committed
sync
1 parent c85fcc0 commit 042e4b8

File tree

1 file changed

+9
-6
lines changed
  • DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/encrypted

1 file changed

+9
-6
lines changed

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/encrypted/table.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""High-level helper class to provide an encrypting wrapper for boto3 DynamoDB tables."""
44
from collections.abc import Callable
5+
from copy import deepcopy
56
from typing import Any
67

78
from boto3.dynamodb.table import BatchWriter
@@ -38,9 +39,10 @@ class EncryptedTable(EncryptedBotoInterface):
3839
3940
The API matches the standard boto3 DynamoDB table interface:
4041
41-
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/table.html
42+
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/table/index.html
4243
4344
This class will encrypt/decrypt items for the following operations:
45+
4446
* ``put_item``
4547
* ``get_item``
4648
* ``query``
@@ -51,7 +53,7 @@ class EncryptedTable(EncryptedBotoInterface):
5153
Calling ``batch_writer()`` will return a ``BatchWriter`` that transparently encrypts batch write requests.
5254
5355
Any other operations on this class will defer to the underlying boto3 DynamoDB Table's implementation
54-
and will not be encrypted/decrypted.
56+
and will not be encrypted/decrypted.
5557
"""
5658

5759
def __init__(
@@ -119,7 +121,7 @@ def get_item(self, **kwargs) -> dict[str, Any]:
119121
120122
Returns:
121123
dict: The response from DynamoDB. This matches the boto3 Table ``get_item`` response syntax.
122-
The value in ``"Item"`` will be decrypted locally after being read from DynamoDB.
124+
The value in ``"Item"`` will be decrypted locally after being read from DynamoDB.
123125
124126
"""
125127
return self._table_operation_logic(
@@ -149,7 +151,7 @@ def query(self, **kwargs) -> dict[str, Any]:
149151
150152
Returns:
151153
dict: The response from DynamoDB. This matches the boto3 Table ``query`` response syntax.
152-
The value in ``"Items"`` will be decrypted locally after being read from DynamoDB.
154+
The value in ``"Items"`` will be decrypted locally after being read from DynamoDB.
153155
154156
"""
155157
return self._table_operation_logic(
@@ -179,7 +181,7 @@ def scan(self, **kwargs) -> dict[str, Any]:
179181
180182
Returns:
181183
dict: The response from DynamoDB. This matches the boto3 Table ``scan`` response syntax.
182-
The value in ``"Items"`` will be decrypted locally after being read from DynamoDB.
184+
The value in ``"Items"`` will be decrypted locally after being read from DynamoDB.
183185
184186
"""
185187
return self._table_operation_logic(
@@ -268,9 +270,10 @@ def _table_operation_logic(
268270
dict: The transformed response from DynamoDB
269271
270272
"""
273+
table_input = deepcopy(operation_input)
271274
# EncryptedTable inputs are formatted as standard dictionaries, but DBESDK transformations expect DynamoDB JSON.
272275
# Convert from standard dictionaries to DynamoDB JSON.
273-
input_transform_input = input_resource_to_client_shape_transform_method(operation_input)
276+
input_transform_input = input_resource_to_client_shape_transform_method(table_input)
274277

275278
# Apply DBESDK transformation to the input
276279
input_transform_output = input_encryption_transform_method(

0 commit comments

Comments
 (0)