You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's based on boto3's [DynamoDB TypeDeserializer](https://boto3.amazonaws.com/v1/documentation/api/latest/_modules/boto3/dynamodb/types.html). # noqa: E501
Copy file name to clipboardExpand all lines: docs/upgrade.md
+45Lines changed: 45 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Changes at a glance:
14
14
* The **legacy SQS batch processor** was removed.
15
15
* The **Idempotency key** format changed slightly, invalidating all the existing cached results.
16
16
* The **Feature Flags and AppConfig Parameter utility** API calls have changed and you must update your IAM permissions.
17
+
* The **`DynamoDBStreamEvent`** replaced `AttributeValue` with native Python types.
17
18
18
19
???+ important
19
20
Powertools for Python v2 drops suport for Python 3.6, following the Python 3.6 End-Of-Life (EOL) reached on December 23, 2021.
@@ -161,3 +162,47 @@ Using qualified names prevents distinct functions with the same name to contend
161
162
AWS AppConfig deprecated the current API (GetConfiguration) - [more details here](https://github.com/awslabs/aws-lambda-powertools-python/issues/1506#issuecomment-1266645884).
162
163
163
164
You must update your IAM permissions to allow `appconfig:GetLatestConfiguration` and `appconfig:StartConfigurationSession`. There are no code changes required.
165
+
166
+
## DynamoDBStreamEvent in Event Source Data Classes
167
+
168
+
???+ info
169
+
This also applies if you're using [**`BatchProcessor`**](https://awslabs.github.io/aws-lambda-powertools-python/latest/utilities/batch/#processing-messages-from-dynamodb){target="_blank"} to handle DynamoDB Stream events.
170
+
171
+
You will now receive native Python types when accessing DynamoDB records via `keys`, `new_image`, and `old_image` attributes in `DynamoDBStreamEvent`.
172
+
173
+
Previously, you'd receive a `AttributeValue` instance and need to deserialize each item to the type you'd want for convenience, or to the type DynamoDB stored via `get_value` method.
174
+
175
+
With this change, you can access data deserialized as stored in DynamoDB, and no longer need to recursively deserialize nested objects (Maps) if you had them.
176
+
177
+
???+ note
178
+
For a lossless conversion of DynamoDB `Number` type, we follow AWS Python SDK (boto3) approach and convert to `Decimal`.
179
+
180
+
```python hl_lines="15-20 24-25"
181
+
from aws_lambda_powertools.utilities.data_classes.dynamo_db_stream_event import (
Copy file name to clipboardExpand all lines: docs/utilities/data_classes.md
+5-11Lines changed: 5 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -797,9 +797,9 @@ This example is based on the AWS Cognito docs for [Verify Auth Challenge Respons
797
797
798
798
### DynamoDB Streams
799
799
800
-
The DynamoDB data class utility provides the base class for `DynamoDBStreamEvent`, a typed class for
801
-
attributes values (`AttributeValue`), as well as enums for stream view type (`StreamViewType`) and event type
800
+
The DynamoDB data class utility provides the base class for `DynamoDBStreamEvent`, as well as enums for stream view type (`StreamViewType`) and event type.
802
801
(`DynamoDBRecordEventName`).
802
+
The class automatically deserializes DynamoDB types into their equivalent Python types.
803
803
804
804
=== "app.py"
805
805
@@ -823,21 +823,15 @@ attributes values (`AttributeValue`), as well as enums for stream view type (`St
823
823
824
824
```python
825
825
from aws_lambda_powertools.utilities.data_classes import event_source, DynamoDBStreamEvent
826
-
from aws_lambda_powertools.utilities.data_classes.dynamo_db_stream_event import AttributeValueType, AttributeValue
827
826
from aws_lambda_powertools.utilities.typing import LambdaContext
0 commit comments