2
2
# SPDX-License-Identifier: Apache-2.0
3
3
"""High-level helper class to provide an encrypting wrapper for boto3 DynamoDB tables."""
4
4
from collections .abc import Callable
5
+ from copy import deepcopy
5
6
from typing import Any
6
7
7
8
from boto3 .dynamodb .table import BatchWriter
@@ -38,9 +39,10 @@ class EncryptedTable(EncryptedBotoInterface):
38
39
39
40
The API matches the standard boto3 DynamoDB table interface:
40
41
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
42
43
43
44
This class will encrypt/decrypt items for the following operations:
45
+
44
46
* ``put_item``
45
47
* ``get_item``
46
48
* ``query``
@@ -51,7 +53,7 @@ class EncryptedTable(EncryptedBotoInterface):
51
53
Calling ``batch_writer()`` will return a ``BatchWriter`` that transparently encrypts batch write requests.
52
54
53
55
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.
55
57
"""
56
58
57
59
def __init__ (
@@ -119,7 +121,7 @@ def get_item(self, **kwargs) -> dict[str, Any]:
119
121
120
122
Returns:
121
123
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.
123
125
124
126
"""
125
127
return self ._table_operation_logic (
@@ -149,7 +151,7 @@ def query(self, **kwargs) -> dict[str, Any]:
149
151
150
152
Returns:
151
153
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.
153
155
154
156
"""
155
157
return self ._table_operation_logic (
@@ -179,7 +181,7 @@ def scan(self, **kwargs) -> dict[str, Any]:
179
181
180
182
Returns:
181
183
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.
183
185
184
186
"""
185
187
return self ._table_operation_logic (
@@ -268,9 +270,10 @@ def _table_operation_logic(
268
270
dict: The transformed response from DynamoDB
269
271
270
272
"""
273
+ table_input = deepcopy (operation_input )
271
274
# EncryptedTable inputs are formatted as standard dictionaries, but DBESDK transformations expect DynamoDB JSON.
272
275
# 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 )
274
277
275
278
# Apply DBESDK transformation to the input
276
279
input_transform_output = input_encryption_transform_method (
0 commit comments