Skip to content

Releases: aws-powertools/powertools-lambda-python

v1.16.1

23 May 09:21
578b01e
Compare
Choose a tag to compare

Summary

Emergency release to patch Pydantic against CVE-2021-29510used by Parser utility - This causes resource starvation when parsing infinity/-inf values.

Thanks to @risenberg-cyberark for the quick turnaround.

Changes

  • feat(parser): security issue in Pydantic #436 (#437) by @risenberg-cyberark

This release was made possible by the following contributors:

@risenberg-cyberark

v1.16.0

17 May 15:04
d9c0217
Compare
Choose a tag to compare

Summary

This release adds support for CodePipeline Job event, and a new property to save you some keystrokes when decoding base64 encoded data in API Gateway and ALB when using Data Classes utility.

CodePipeline Job support

If you're new to the CodePipeline Job event, customers typically use it for out of band integrations, such as orchestrate heavy deployments with a State Machine or validate an external system/KPI before continuing.

This release adds support for CodePipeline Job including methods to easily retrieve user parameters, download artifacts from S3 using temporary credentials sent as part of event, etc.

image

Base64 decode support

Based on this thread on Twitter with Luc from SentiaCloud, decoding base64 data in the first try without looking at a snippet is not for everyone :D

When using Data classes for API Gateway or ALB, you can now easily decode data with the new decoded_body property:

from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent


def lambda_handler(event: dict, context):
    event = APIGatewayProxyEvent(event)
    # Dynamically base64 decode body as a str
    body: str = event.decoded_body
    
    return body

Changes

🌟 New features and non-breaking changes

🌟 Minor Changes

This release was made possible by the following contributors:

@heitorlessa and @michaelbrewer

v1.15.1

13 May 11:34
93fad02
Compare
Choose a tag to compare

Summary

Quick release to fix a regression in Logger for the %s operator.

Changes

🌟 Minor Changes

  • fix(logger): Support .info("foo %s", "bar") formatting (#426) by @huonw

📜 Documentation updates

This release was made possible by the following contributors:

@heitorlessa, @huonw and @michaelbrewer

v1.15.0

06 May 07:36
bd1dbf0
Compare
Choose a tag to compare

Summary

This release has three major goodies: 1/ Idempotency utility is now GA, 2/ New API Gateway and ALB event handler, and 3/ MANY enhancements to Logger.

Idempotency

Idempotency utility was introduced in 1.11.0 as beta. If you haven't used it yet, it converts Lambda functions into idempotent operations that are safe to retry - This is mostly needed when your code is not idempotent.

Since launch, we've made improvements to error handling and documentation updates. This gives us confidence that the UX won't radically change and therefore can be used safely moving forward.

Idempotency showcase

API Gateway and ALB event handler

huge thanks to @michaelbrewer

This new utility provides a lightweight routing to reduce boilerplate for API Gateway REST/HTTP API and ALB. It also natively integrates with Data classes utility giving you handy methods and self-documented properties of API Gateway and ALB events.

image

It's important to note that this is not a replacement for fully fledged web frameworks like Flask and Djano, or microframeworks like Chalice. Instead, this gives you a nearly zero overhead (~1-2ms) lightweight solution to build applications on top of either API Gateway or ALB.

As a trade-off for being so lightweight, you have to setup infrastructure to use Lambda Proxy Integration using your preferred framework be that CloudFormation, SAM, CDK, Terraform, etc. Rest assured we provide a sample template to demonstrate how you can configure it if you haven't done this yet.

Did I say CORS is simplified too? :)

image

Logger

This release makes Logger more flexible by allowing you to bring your own Logging Formatter and Handler. It also includes a ton of improvements such as:

  • Easily remap keys or bring own defaults by inheriting the now exposed LambdaPowertoolsFormatter
  • UTC support with as simple as utc=True flag
  • Easier methods to add or remove logging keys at runtime with append_keys() and remove_keys(). The previous method, structure_logs(append=True, ...), will continue to work for backwards compatibility and will be effectively when we decide to cut a major version (2.0) - warnings will be place in time too
  • All keys can be reordered including the ones you're going to introduce yet at runtime
  • sampling_rate key only gets added when feature is added
  • Bring your own JSON serializer or deserializer function like the ultra fast Orjson, for when you need to crunch every possible ms
  • timestamp key now includes timezone at the end: from 2021-05-03 11:47:12,494 to 2021-05-03 11:47:12,494+0200

image

API Gateway support for Parser

huge thanks to @risenberg-cyberark

You can now easily parse and run deep data validation with APIGatewayProxyEvent in Parser, including an envelope ApiGatewayEnvelope.

Metrics

Last but not least, you can now set default metric dimensions to ensure these will always be added across all metrics: metrics.set_default_dimensions(environment="prod", another="one")

Changes

🌟New features and non-breaking changes

  • refactor(event-handler): Add ResponseBuilder and more docs (#412) by @michaelbrewer
  • feat(event-handler): add http ProxyEvent handler (#369) by @michaelbrewer
  • feat(metrics): add support to persist default dimensions (#410) by @heitorlessa
  • refactor(logger): BYOFormatter and Handler, UTC support, and more (#404) by @heitorlessa
  • feat(parser): Support for API GW v1 proxy schema & envelope (#403) by @risenberg-cyberark

🌟 Minor Changes

📜 Documentation updates

🐛 Bug and hot fixes

Internal

This release was made possible by the following contributors:

@carlos-alberto, @heitorlessa, @michaelbrewer and @risenberg-cyberark

v1.14.0

09 Apr 09:56
9be19b2
Compare
Choose a tag to compare

Summary

This release a new Event Handlers core utility, and enables versioning for documentation so you can access staging docs early or a specific release doc.

Additionally, there are a number of enhancements in the documentation, Parser's support for S3 Object Lambda event, a better support for MyPy (more to come), etc.

Event Handlers

This is a new core utility to help you reduce boilerplate when working with Event Sources. For example, you can now have clearly defined single purpose methods to be called depending on what's inside the event instead of nested flow controls (if/else/elif).

AWS AppSync is our first event handler (thanks to @michaelbrewer), and we would love to hear from you what other event handlers would be useful to boost your experience even further.

Notice how you can combine AppSync scalar utilities, Logger correlation ID, Tracer, and have tiny functions to compute a given GraphQL field or type now.

image

Versioned docs

Some of you might have already noticed a new version switch at the top of the documentation, including additional stats from GitHub directly on the top right corner.

This means you can now access early versions of the documentation before we release as well as the last two releases. This opens the door for a possible nightly build release :)

image

Changes

🌟New features and non-breaking changes

  • docs: enable versioning feature (#374) by @heitorlessa
  • feat(event-handler): Add AppSync handler decorator (#363) by @michaelbrewer
  • feat(parser): Add S3 Object Lambda Event (#362) by @risenberg-cyberark

🌟 Minor Changes

📜 Documentation updates

🐛 Bug and hot fixes

🔧 Internal

This release was made possible by the following contributors:

@heitorlessa, @michaelbrewer, @risenberg-cyberark and @rtrive

Discussion: #394

v1.13.0

23 Mar 08:14
921b6c0
Compare
Choose a tag to compare

Summary

Quick release to add support for the new S3 Object Lambda event within Event Source Data Classes utility - Thanks to @michaelbrewer

Event Source Data Classes utility provides self-documented schema for multiple Lambda Event Sources, and helper methods to easily parse, decode, and fetch common attributes, headers, and data in various forms.

image

Changes

🌟New features and non-breaking changes

📜 Documentation updates

🔧 Internal

This release was made possible by the following contributors:

@BrockReece, @heitorlessa and @michaelbrewer

v1.12.0

17 Mar 15:19
590fa3c
Compare
Choose a tag to compare

Changes

This release brings a number of minor but importance enhancements in Logger, Parameters, Data Classes, Idempotency.

Also, this release wouldn't have been possible without @michaelbrewer relentless contribution - Thank you, Michael!!

Logger

You can now inject correlation IDs coming from any Event Source using JMESPath expressions, or by manually injecting a string with set_correltion_id.

image

Another enhancement that goes nicely with any Logging Analytics solution such as Amazon CloudWatch Logs Insights, Kibana, Datadog, Splunk, Loggly, etc is the ability to enumerate exceptions across all your functions - A new field exception_name will be added to your Logs when using logger.exception().

Data Classes

You can now have a self-documented schema for AppSync Lambda Resolvers whether you use Direct Lambda Resolver feature, or @function GraphQL Transformer with Amplify CLI. More importantly, scalar type utilities such as timestamps, timezone offsets, UUIDs, are also available!

image

Another enhancement is additional documentation for Cognito custom auth challenges.

Parameters

A minor enhancement but important for sensitive parameters that cannot be cached. You can now use force_fetch=True parameter to always fetch the latest from your preferred parameter provider be that Parameter Store, Secrets Manager, AppConfig, DynamoDB, or your own.

We have also refreshed Parameters documentation using the new Getting started vs Advanced, including surfacing how you can control in-memory cache TTL for parameters retrieved.

image

Idempotency

Besides error handling improvements, thanks to @Dunedan and @michaelbrewer (#318), you can now reuse a single DynamoDB table to store idempotency state. All new idempotency states stored in your DynamoDB table, as part of this release, will now contain your function name as a prefix for the hash key.

This is one step forward towards GA for Idempotency - The last missing feature before it's GA is allowing an exception callback mechanism so you can handle any exceptions to more easily return custom responses for event sources like API Gateway, AppSync, etc.

🌟New features and non-breaking changes

📜 Documentation updates

🐛 Bug and hot fixes

Internal

This release was made possible by the following contributors:

@heitorlessa and @michaelbrewer

v1.11.0

05 Mar 17:11
696f93e
Compare
Choose a tag to compare

Changes

This is our most special release this quarter, as we are happy to announce:

  1. Up to 75% performance improvement for customers not using Tracer utility due to lazy loading
  2. Up to 40% performance improvement for customers using Metrics as large operations are now <1ms
  3. Brand new Idempotency utility for safely retrying operations that have side-effects, one of the most awaited feature since we've gone GA

Performance improvements

Tracer effect on import time flame graph before and after initial round of optimizations

image

image

Warm execution logging, serializing, and validating 99 Metrics to CloudWatch asynchronously on the lowest Lambda fn memory (128) after all optimizations

image

New idempotency utility

Initially led by @igorlg RFC on Idempotency, and its implementation that started in mid December by @cakepietoast, with a gigantic effort by both @cakepietoast and @michaelbrewer on UX and correctness following Amazon Builder's Library and Stripe designs -- We now have it in Beta as part of this release.

Given the amount of serious work for this utility and its logic, we've decided it'd be best to launch as Beta as we'd like feedback on UX before we release as stable.

Key features at launch:

  • Use DynamoDB as a persistence layer for state including Bring Your Own Persistence Store Layer
  • Optional in-memory caching, idempotency state auto-expiration for cost reasons
  • JMESPath support to select a subset of your payload to serialize and hash as idempotency key
  • Payload validation in case we shouldn't return the previous result in case X parameter has changed in your request
  • Last but not least, the documentation is super comprehensive with over 600 lines of content.

We truly hope you enjoy it :-)

image

image

🌟New features and non-breaking changes

  • feat(data-classes): Add connect contact flow event (#304) by @Sordie
  • feat(idempotency): Add raise_on_no_idempotency_key flag (#297) by @michaelbrewer
  • feat: Idempotency helper utility (#245) by @cakepietoast

🌟 Minor Changes

  • refactor(idempotent): Change UX to use a config class for non-persistence related features (#306) by @michaelbrewer
  • refactor(metrics): optimize validation and serialization (#307) by @heitorlessa
  • feat(idempotent): Add support for jmespath_options (#302) by @michaelbrewer
  • fix(core): import time latency by lazily loading high level modules (#301) by @heitorlessa

📜 Documentation updates

🐛 Bug and hot fixes

  • test(general): Add some missing code coverage (#296) by @michaelbrewer
  • feat(idempotency): Fix KeyError when local_cache is True and an error is raised in the lambda handler (#300) by @michaelbrewer
  • fix: correct behaviour to avoid caching "INPROGRESS" records (#295) by @cakepietoast

This release was made possible by the following contributors:

@Sordie, @cakepietoast, @heitorlessa and @michaelbrewer

v1.10.5

17 Feb 13:39
b5ada70
Compare
Choose a tag to compare

Changes

No code changes. Release to re-trigger layer publish.

  • chore: version bump to 1.10.5 (#292) by @cakepietoast

This release was made possible by the following contributors:

@cakepietoast

v1.10.4

17 Feb 08:47
103d215
Compare
Choose a tag to compare

Changes

Releasing a new version primarily to update the published "extras" Lambda layer, as it was not being built correctly (see #290). Also including some fixes for the recently updated documentation thanks to @michaelbrewer.

📜 Documentation updates

Internal

  • chore: version bump to 1.10.4 (#291) by @cakepietoast

This release was made possible by the following contributors:

@cakepietoast, @heitorlessa and @michaelbrewer