Summary
This release improves the authoring experience for Batch processing (-boilerplate), fix a bug between Batch and Pydantic integration for poison pills, and several documentation and static typing improvements!
⭐ Huge thanks to new contributors: @michael-k (docs) and @LuckIlNe (Batch pydantic bugfix)
No more decorators for Batch Processing
Docs: Amazon SQS, Amazon Kinesis Data Streams, Amazon DynamoDB Streams
Batch feature is generally used for building more resilient data pipelines ranging from ETL to Change Data Capture to AWS automation.
This release significantly removes boilerplate and makes it less error prone to author batch processors. You can now use process_partial_response
and async_process_partial_response
within your Lambda handler to kick off processing, handle failures and return the expected response for partial failures in Lambda.
Before
After
Addressing poison pill issue with Batch and Pydantic model validation
Pydantic provides parsing and deep data validation mechanisms. It's commonly used with Batch feature to author and validate data models.
Thanks to @LuckIlNe, we now correctly handle malformed messages that fail validation early (poison pills), thus not breaking the partial failure mechanism. Previously, any record that doesn't conform with an early model validation would not fail gracefully.
Documentation improvements
Idempotency
Docs: Idempotency new diagrams, terminology, and Idempotency record expiration vs DynamoDB time-to-live (TTL).
Thanks to a discussion with @pmarko1711, we revamped the Idempotency documentation to include more sequence diagrams to visually explain the different idempotent scenarios. We also clarified terminologies like Idempotency Record, and a confusion between Idempotency Record Expiration and DynamoDB TTL.
The latter can be used as a fine-grained concurrency mechanism.
Batch
Pydantic integration examples now use the new Json
model from Pydantic to auto-deserialize JSON strings into Pydantic models. This removes excessive boilerplate when working with SQS and Kinesis Data Streams in Batch.
All examples now recommend use of process_partial_response
over the legacy decorator, including a new question in the FAQ section to clarify them.
Static typing improvements in Parser
When using Mypy for applications using Pydantic models provided by Parser, you couldn't use nested models for SQS, Kinesis, and DynamoDB Streams.
This quality of life improvement also allows you to use higher-level models like Json
to auto-deserialize JSON strings in common Lambda Event Source fields like SQS.body
.
from aws_lambda_powertools.utilities.parser import BaseModel, validator
from aws_lambda_powertools.utilities.parser.models import (
DynamoDBStreamChangedRecordModel,
DynamoDBStreamRecordModel,
KinesisDataStreamRecord,
KinesisDataStreamRecordPayload,
SqsRecordModel,
)
from aws_lambda_powertools.utilities.parser.types import Json, Literal
class Order(BaseModel):
item: dict
# SQS example
class OrderSqs(SqsRecordModel):
body: Json[Order]
# Kinesis example
class OrderKinesisPayloadRecord(KinesisDataStreamRecordPayload):
data: Json[Order]
class OrderKinesisRecord(KinesisDataStreamRecord):
kinesis: OrderKinesisPayloadRecord
# DynamoDB Streams example
class OrderDynamoDBChangeRecord(DynamoDBStreamChangedRecordModel):
NewImage: Optional[OrderDynamoDB]
OldImage: Optional[OrderDynamoDB]
class OrderDynamoDBRecord(DynamoDBStreamRecordModel):
dynamodb: OrderDynamoDBChangeRecord
Changes
🌟New features and non-breaking changes
- feat(batch): reduce boilerplate with process_partial_response (#2090) by @heitorlessa
- feat(idempotency): allow custom sdk clients in DynamoDBPersistenceLayer (#2087) by @heitorlessa
📜 Documentation updates
- docs(batch): use newly supported Json model (#2100) by @heitorlessa
- feat(batch): reduce boilerplate with process_partial_response (#2090) by @heitorlessa
- docs(homepage): remove banner for end-of-support v1 (#2098) by @leandrodamascena
- docs(idempotency): fixes to testing your code section (#2073) by @leandrodamascena
- docs(parser): fix highlighted line (#2064) by @michael-k
- docs(idempotency): new sequence diagrams, fix idempotency record vs DynamoDB TTL confusion (#2074) by @heitorlessa
🐛 Bug and hot fixes
- fix(batch): handle early validation errors for pydantic models (poison pill) #2091 (#2099) by @LuckIlNe
🔧 Maintenance
- chore(deps-dev): bump aws-cdk-lib from 2.72.1 to 2.73.0 (#2097) by @dependabot
- chore(deps-dev): bump filelock from 3.10.7 to 3.11.0 (#2094) by @dependabot
- chore(deps-dev): bump coverage from 7.2.2 to 7.2.3 (#2092) by @dependabot
- chore(deps-dev): bump aws-cdk from 2.72.1 to 2.73.0 (#2093) by @dependabot
- chore(deps-dev): bump mypy-boto3-cloudformation from 1.26.60 to 1.26.108 (#2095) by @dependabot
- chore(deps-dev): bump types-python-dateutil from 2.8.19.11 to 2.8.19.12 (#2085) by @dependabot
- chore(deps-dev): bump cfn-lint from 0.76.1 to 0.76.2 (#2084) by @dependabot
- chore(deps-dev): bump aws-cdk from 2.72.0 to 2.72.1 (#2081) by @dependabot
- chore(deps): bump aws-xray-sdk from 2.11.0 to 2.12.0 (#2080) by @dependabot
- chore(deps-dev): bump mkdocs-material from 9.1.4 to 9.1.5 (#2077) by @dependabot
- chore(deps-dev): bump aws-cdk-lib from 2.72.0 to 2.72.1 (#2076) by @dependabot
- chore(deps-dev): bump mypy-boto3-s3 from 1.26.99 to 1.26.104 (#2075) by @dependabot
- chore(deps-dev): bump aws-cdk from 2.71.0 to 2.72.0 (#2071) by @dependabot
- chore(deps): bump peaceiris/actions-gh-pages from 3.9.2 to 3.9.3 (#2069) by @dependabot
- chore(deps-dev): bump aws-cdk-lib from 2.71.0 to 2.72.0 (#2070) by @dependabot
- chore(deps-dev): bump black from 23.1.0 to 23.3.0 (#2066) by @dependabot
- chore(deps-dev): bump aws-cdk from 2.70.0 to 2.71.0 (#2067) by @dependabot
- chore(deps-dev): bump aws-cdk-lib from 2.70.0 to 2.71.0 (#2065) by @dependabot
This release was made possible by the following contributors:
@LuckIlNe, @dependabot, @dependabot[bot], @heitorlessa, @leandrodamascena, @michael-k and Release bot