Skip to content

Releases: aws-powertools/powertools-lambda-python

v1.5.0

04 Sep 10:51
063d8cd
Compare
Choose a tag to compare

Changes

SQS batch processing utility

Add a new utility to handle partial failures when processing batches of SQS messages in Lambda. The default behaviour with Lambda - SQS is to return all messages to the queue when there is a failure during processing. This utility provides functionality to handle failures individually at the message level, and avoid re-processing messages. Thanks to @gmcrocetti who contributed this utility.

Integration with CloudWatch ServiceLens

The xray_trace_id key is now added to log output when tracing is active. This enables the log correlation functionality in ServiceLens to work with applications using powertools.

Static types for Lambda context object

You can now import a static type for the Lambda context object from this library. Thanks to @Nr18 for the implementation.

Control order of logging output

You can now change the order of the fields output by the logger. Thanks to @michaelbrewer for the implementation.

Automatically deserialize parameters

Thanks to @michaelbrewer, the parameters utility can now automatically decide how to deserialize parameter values (json/base64) based on the key name.

Documentation improvements

Lots of improvements made to the documentation. Thanks to the community contributors: @Nr18 for adding a troubleshooting section, @michaelbrewer and @bls20AWS for several housekeeping contributions.

🌟 Minor Changes

📜 Documentation updates

🐛 Bug and hot fixes

  • fix: batch processing util (#155) by @cakepietoast

This release was made possible by the following contributors:

@Nr18, @am29d, @bls20AWS, @cakepietoast, @gmcrocetti, @heitorlessa, @michaelbrewer and @pankajagrawal16

v1.4.0

25 Aug 16:10
814062e
Compare
Choose a tag to compare

Changes

Official Lambda Layer

We now provide an official Lambda Layer via AWS Serverless Application Repository (SAR) App. SAR App follows semantic versioning, and it is synchronized with what's published on PyPi.

SAR App ARN
aws-lambda-powertools-python-layer arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer

A big thanks to @am29d for the implementation, and to Keith Rosario, a long standing contributor, and beta customer, who created the first Layers through his KLayers project - Lambda Layers for Python on GitHub before.

Auto-complete for SSMProvider on Parameters utility

Thanks to @michaelbrewer, SSMProvider within Parameters utility now have decrypt and recursive parameters correctly defined to support autocompletion.

Tracer support to not capture response as metadata

For customers returning sensitive information from their methods and Lambda handlers, Tracer decorators capture_method and capture_lambda_handler now support capture_response=False parameter to override this behaviour.

Cold start metric bugfix

This release ensures Metrics utility creates a Cold Start metric with dedicated CloudWatch dimensions function_name and service to explicitly separate Application metrics from System metrics.
Previously, when capturing cold start metric via capture_cold_start_metric parameter, we would add ColdStart metric to an existing metric set along with function_name as a dimension. This caused the problem of Application metrics having data points in two separate metrics with the same name, since one of them would have an additional function_name dimension in the event of a cold start.

Minor improvements to docs

Content in Tracer and Logger have been reordered to match what customers are looking for. Tracer docs have less main sections to improve navigation, a new section named Patching Modules, and a note for customers capturing sensitive information they might not want Tracer to capture it.

🌟 Minor Changes

  • feat: add workflow to trigger external pipeline for publishing lambda layers (#129) by @am29d
  • feat: option to disallow tracer to capture response as metadata (#128) by @heitorlessa

📜 Documentation updates

🐛 Bug and hot fixes

  • fix: split cold start metric from application metrics to prevent duplicate app metrics (#126) by @heitorlessa
  • fix(ssm): Make decrypt an explicit option and refactoring (#123) by @michaelbrewer

This release was made possible by the following contributors:

@am29d, @heitorlessa and @michaelbrewer

v1.3.1

22 Aug 09:06
Compare
Choose a tag to compare

Changes

Fixed issue with capture_method returning not working properly when the decorated function made us of context managers during its execution.

Patch

  • fix(capture_method): should yield inside with for generator method using a context manager (#124) by @michaelbrewer

Chore

  • chore(deps): bump elliptic from 6.5.2 to 6.5.3 in /docs (#120) by @dependabot
  • chore(deps): bump prismjs from 1.20.0 to 1.21.0 in /docs (#121) by @dependabot

This release was made possible by the following contributors:

@cakepietoast, @dependabot, @heitorlessa and @michaelbrewer

v1.3.0

21 Aug 14:06
41824b1
Compare
Choose a tag to compare

Changes

Sample code snippet of the parameters utility

Add a new utility to fetch and cache parameter values from AWS Systems Manager Parameter Store, AWS Secrets Manager or Amazon DynamoDB. It also provides a base class to create your parameter provider implementation.

Retrieve values from Systems Manager Parameter Store:

from aws_lambda_powertools.utilities import parameters

def handler(event, context):
    # Retrieve a single parameter
    value = parameters.get_parameter("/my/parameter")

    # Retrieve multiple parameters from a path prefix recursively
    # This returns a dict with the parameter name as key
    values = parameters.get_parameters("/my/path/prefix")
    for k, v in values.items():
        print(f"{k}: {v}")

Retrieve secrets from AWS Secrets Managers:

from aws_lambda_powertools.utilities import parameters

def handler(event, context):
    # Retrieve a single secret
    value = parameters.get_secret("my-secret")

🌟 Minor Changes

This release was made possible by the following contributors:

@nmoutschen

v1.2.0

20 Aug 16:21
8621d4e
Compare
Choose a tag to compare

Changes

The Tracer capture_method decorator can now be used to capture execution of generator functions, including context managers.

  • chore: bump version to 1.2.0 (#119) by @cakepietoast

🌟 Minor Changes

  • feat: add support for tracing of generators using capture_method decorator (#113) by @cakepietoast

This release was made possible by the following contributors:

@cakepietoast

v1.1.3

18 Aug 20:28
81539a0
Compare
Choose a tag to compare

Changes

Fix logged messages being emitted twice, once structured and once unstructured - We now remove the root logger handler set by Lambda during initialization.

Patch

Chore

This release was made possible by the following contributors:

@heitorlessa

v1.1.2

16 Aug 17:39
6b66e0b
Compare
Choose a tag to compare

Changes

Minor patch to improve Tracer documentation on reusability, and ensures PyCharm/VSCode Jedi Language Server can autocomplete log statements for Logger.

📜 Documentation updates

This release was made possible by the following contributors:

@heitorlessa @michaelbrewer

v1.1.1

14 Aug 19:18
24a3bdf
Compare
Choose a tag to compare

Changes

Fix Logger regression introduced in 1.1.0 when using int for setting log level, for example Logger(level=logging.INFO).

Patch

Chore

This release was made possible by the following contributors:

@heitorlessa, and big thanks to @zroger for spotting and raising this regression

v1.1.0

14 Aug 16:10
d3feb63
Compare
Choose a tag to compare

Changes

This release add support for reusing Logger across multiple files in your code base via the new child parameter 🎉🎉🎉

Child Loggers will be named after the convention {service}.{filename} - It now follows the Python Logging inheritance mechanics. Here's a code excerpt to demonstrate how this feature looks like:

app.py - Your typical parent logger will be at your Lambda function handler

# POWERTOOLS_SERVICE_NAME: "payment"
import shared # Creates a child logger named "payment.shared"
from aws_lambda_powertools import Logger

logger = Logger()

def handler(event, context):
  shared.inject_payment_id(event) # highlight-line
  logger.structure_logs(append=True, order_id=event["order_id"]) # highlight-line
      ...

shared.py - You can use Logger(child=True) to explicit tell Logger this should be the child

# POWERTOOLS_SERVICE_NAME: "payment"
from aws_lambda_powertools import Logger

logger = Logger(child=True) # highlight-line

def inject_payment_id(event):
    logger.structure_logs(append=True, payment_id=event["payment_id"])

🌟 Minor Changes

Chore

  • chore(deps): bump lodash from 4.17.15 to 4.17.19 in /docs (#93) by @dependabot

This release was made possible by the following contributors:

@heitorlessa @alexanderluiscampino

v1.0.2

16 Jul 14:23
6db7263
Compare
Choose a tag to compare

Changes

This release allows the latest version of X-Ray SDK (2.6.0) to be installed, and no longer locks to the previous version (2.5.0).

Chore

This release was made possible by the following contributors:

@Nr18 and @heitorlessa