aws_dbesdk_dynamodb.encrypted.table
High-level helper class to provide an encrypting wrapper for boto3 DynamoDB tables.
Classes
|
Wrapper for a boto3 DynamoDB table that transparently encrypts/decrypts items. |
- class aws_dbesdk_dynamodb.encrypted.table.EncryptedTable(*, table: ServiceResource, encryption_config: DynamoDbTablesEncryptionConfig)
Bases:
EncryptedBotoInterfaceWrapper for a boto3 DynamoDB table that transparently encrypts/decrypts items.
This class implements the complete boto3 DynamoDB table API, allowing it to serve as a drop-in replacement that transparently handles encryption and decryption of items.
The API matches the standard boto3 DynamoDB table interface:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/table/index.html
This class will encrypt/decrypt items for the following operations:
put_itemget_itemqueryscandelete_item
Any calls to
update_itemcan only update unsigned attributes. If an attribute to be updated is marked as signed, this operation will raise aDynamoDbEncryptionTransformsException.Calling
batch_writer()will return aBatchWriterthat transparently encrypts batch write requests.Any other operations on this class will defer to the underlying boto3 DynamoDB Table’s implementation and will not be encrypted/decrypted.
Create an
EncryptedTableobject.- Parameters:
table (ServiceResource) – Initialized boto3 DynamoDB table
encryption_config (DynamoDbTablesEncryptionConfig) – Initialized DynamoDbTablesEncryptionConfig
- __init__(*, table: ServiceResource, encryption_config: DynamoDbTablesEncryptionConfig)
Create an
EncryptedTableobject.- Parameters:
table (ServiceResource) – Initialized boto3 DynamoDB table
encryption_config (DynamoDbTablesEncryptionConfig) – Initialized DynamoDbTablesEncryptionConfig
- put_item(**kwargs) dict[str, Any]
Put a single item to the table. Encrypts the item before writing to DynamoDB.
The input and output syntaxes match those for the boto3 DynamoDB table
put_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 Table
put_itemrequest syntax. The value in"Item"will be encrypted locally before being written to DynamoDB.- Returns:
The response from DynamoDB. This matches the boto3
put_itemresponse syntax.- Return type:
- get_item(**kwargs) dict[str, Any]
Get a single item from the table. Decrypts the item after reading from DynamoDB.
The input and output syntaxes match those for the boto3 DynamoDB table
get_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 Table
get_itemrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 Table
get_itemresponse syntax. The value in"Item"will be decrypted locally after being read from DynamoDB.- Return type:
- query(**kwargs) dict[str, Any]
Query items from the table or index. Decrypts any returned items.
The input and output syntaxes match those for the boto3 DynamoDB table
queryAPI:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/table/query.html
- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 Table
queryrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 Table
queryresponse syntax. The value in"Items"will be decrypted locally after being read from DynamoDB.- Return type:
- scan(**kwargs) dict[str, Any]
Scan the entire table or index. Decrypts any returned items.
The input and output syntaxes match those for the boto3 DynamoDB table
scanAPI:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/table/scan.html
- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 Table
scanrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 Table
scanresponse syntax. The value in"Items"will be decrypted locally after being read from DynamoDB.- Return type:
- delete_item(**kwargs) dict[str, Any]
Delete an item from the table.
The input and output syntaxes match those for the boto3 DynamoDB table
delete_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 Table
delete_itemrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 Table
delete_itemresponse syntax. Any values in"Attributes"will be decrypted locally after being read from DynamoDB.- Return type:
- update_item(**kwargs)
Update an unsigned attribute in the table.
If the attribute is signed, this operation will raise DynamoDbEncryptionTransformsException.
The input and output syntaxes match those for the boto3 DynamoDB table
update_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 Table
update_itemrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 Table
update_itemresponse syntax.- Return type:
- Raises:
DynamoDbEncryptionTransformsException – If an attribute specified in the
UpdateExpressionis signed.
- batch_writer(overwrite_by_pkeys: list[str] | None = None) BatchWriter
Create a batch writer object that will transparently encrypt requests to DynamoDB.
- Parameters:
overwrite_by_pkeys – De-duplicate request items in buffer if match new request item on specified primary keys. i.e
["partition_key1", "sort_key2", "sort_key3"]- Returns:
A batch writer that will transparently encrypt requests
- Return type:
BatchWriter