in src/dynamodb_encryption_sdk/material_providers/aws_kms.py [0:0]
def _attribute_to_value(self, attribute):
# type: (dynamodb_types.ITEM) -> Text
"""Convert a DynamoDB attribute to a value that can be added to the KMS encryption context.
:param dict attribute: Attribute to convert
:returns: value from attribute, ready to be addd to the KMS encryption context
:rtype: str
"""
attribute_type, attribute_value = list(attribute.items())[0]
if attribute_type == "B":
return base64.b64encode(attribute_value).decode(TEXT_ENCODING)
if attribute_type in ("S", "N"):
return attribute_value
raise ValueError('Attribute of type "{}" cannot be used in KMS encryption context.'.format(attribute_type))