github aws-powertools/powertools-lambda-python v1.10.1

latest releases: v2.40.1, v2.40.0, v2.39.1...
3 years ago

Changes

This release patches a model mismatch when using SNS -> SQS -> Lambda as opposed to SNS -> Lambda. The former changes three keys that are incompatible with the model we derived from Lambda:

  • MessageAttributes key is not present
  • UnsubscribeUrl becomes UnsubscribeURL
  • SigningCertUrl becomes SigningCertURL

This release also introduces a new envelope, SnsSqsEnvelope, to make this process seamless and easier when processing messages in Lambda that come from SNS -> SQS. This will extract the original SNS published payload, unmarshall it, and parse it using your model.

from aws_lambda_powertools.utilities.parser import BaseModel, envelopes, event_parser

class MySnsBusiness(BaseModel):
    message: str
    username: str

@event_parser(model=MySnsBusiness, envelope=envelopes.SnsSqsEnvelope)
def handle_sns_sqs_json_body(event: List[MySnsBusiness], _: LambdaContext):
    assert len(event) == 1
    assert event[0].message == "hello world"
    assert event[0].username == "lessa"

🌟 Minor Changes

Maintenance

This release was made possible by the following contributors:

@heitorlessa

Don't miss a new powertools-lambda-python release

NewReleases is sending notifications on new releases.