github aws-powertools/powertools-lambda-python v3.0.0

10 hours ago

Summary

We are super happy to announce our new major version – v3.0.0 🎉🎉!

We have made Pydantic v2 the default for Powertools for AWS Lambda (Python) utilities, this was the most requested feature from you. Pydantic v2 is the most impactful upgrade, offering better performance and greater flexibility compared to Pydantic v1.

The second most requested feature was publishing Powertools Lambda layers for different Python versions and architectures, allowing for easier integration across various Lambda environments. This is crucial for libraries like Pydantic v2 and AWS Encryption SDK, which are used by Powertools and require installation for specific architectures and Python version.

🌟 We couldn’t have done this without you 🌟

Thanks to everyone in the community for their patience and assistance as we've been working on this release. A special thanks to @ericbn for their amazing contributions to this milestone.

We care deeply about minimizing breaking changes

Over the past few months, we carefully selected each breaking change to make, and crafted an extensive upgrade guide to ease your transition to v3. Please let us know whether we can make your upgrade process easier.

Note

The section below is an excerpt of what's available in the Upgrade guide

What’s New in v3

  • Drop support for Pydantic v1
  • New AWS Lambda Layer ARNs
  • New default values for Event Source Data Classes
  • Headers are now case-insensitive in Event Handler
  • Backwards incompatible changes

Drop support for Pydantic v1

We no longer support Pydantic v1 and have updated our toolkit to support only v2 of the library. We made this change after Pydantic v1 reached End-of-Life on June 2024.

Use the Pydantic v2 Migration Guide to migrate your custom Pydantic models to v2.

New AWS Lambda Layer ARNs

To give you a better experience, we're now building our public Powertools for AWS Lambda (Python)'s Lambda layers for specific Python versions (3.8-3.12) and architectures (x86_64 & arm64).

With this change we can now include architecture-specific versions of both Pydantic v2 and AWS Encryption SDK and give you a more streamlined setup.

To take advantage of the new layers, you need to update your functions or deployment setup to include one of the new Lambda layer ARN from the table below:

Architecture Python Version Layer ARN
x86_64 3.8 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python38-x86:{version}
x86_64 3.9 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python39-x86:{version}
x86_64 3.10 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python310-x86:{version}
x86_64 3.11 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86:{version}
x86_64 3.12 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python312-x86:{version}
arm64 3.8 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python38-arm64:{version}
arm64 3.9 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python39-arm64:{version}
arm64 3.10 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python310-arm64:{version}
arm64 3.11 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-arm64:{version}
arm64 3.12 arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python312-arm64:{version}

Event Source Data Classes default values

We have modified the Event Source Data classes so optional dictionaries and lists now return empty dictionaries or lists instead of None. This improvement simplifies your code by eliminating the need for conditional checks when accessing these fields, while maintaining backward compatibility with previous implementations.

data_class

Event Handler: headers are case-insensitive

According to the HTTP RFC, HTTP headers must be case-insensitive. As a result, we have deprecated the get_header_value function to align with this standard. Instead, we recommend using app.current_event.headers.get to access header values directly.

Consequently, the case_sensitive parameter in this function no longer has any effect, as we now ensure consistent casing by normalizing headers for you. This function will be removed in a future release, and we encourage you to adopt the new method to access header values.

event_handler

Backwards incompatible changes

Area Change Code Change Required
Pydantic We have removed support for Pydantic v1 No
Parser We have eplaced DynamoDBStreamModel AttributeValue with native Python types Yes
Lambda Layer Lambda layers are now compiled according to the specific Python version and architecture No
Event Handler Headers are case-insensitive, and we have deprecated the get_header_value function. Yes
Batch Processor @batch_processor and @async_batch_processor decorators are now deprecated Yes
Event Source Data Classes We have updated default values for optional fields. Yes
Parameters The default cache TTL is now set to 5 minutes No
Parameters The config parameter is deprecated in favor of boto_config Yes
JMESPath Functions The extract_data_from_envelope function is deprecated in favor of query Yes
Types File We have removed the type imports from the shared/types.py file Yes

This release was made possible by the following contributors:

@ericbn, @github-actions, @github-actions[bot], @sthulb, and @leandrodamascena

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

NewReleases is sending notifications on new releases.