Releases: aws-powertools/powertools-lambda-python
v1.16.1
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
This release was made possible by the following contributors:
@risenberg-cyberark
v1.16.0
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.
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
- feat(data-classes): support for code pipeline job event (#416) by @michaelbrewer
🌟 Minor Changes
- feat(data-classes): decode base64 encoded body (#425) by @michaelbrewer
This release was made possible by the following contributors:
v1.15.1
Summary
Quick release to fix a regression in Logger for the %s
operator.
Changes
🌟 Minor Changes
📜 Documentation updates
- fix(docs): Use updated names for ProxyEventType (#424) by @michaelbrewer
This release was made possible by the following contributors:
v1.15.0
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.
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.
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? :)
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()
andremove_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: from2021-05-03 11:47:12,494
to2021-05-03 11:47:12,494+0200
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
- feat(event-handler): allow for
cors=None
setting (#421) by @michaelbrewer - refactor(event-handler): api gateway handler review changes (#420) by @michaelbrewer
- refactor: simplify custom formatter for minor changes (#417) by @heitorlessa
📜 Documentation updates
- docs(api_gateway): new event handler for API Gateway and ALB (#418) by @heitorlessa
- docs(logger): improvements extensibility & new features (#415) by @heitorlessa
- fix(docs): workflow to include api ref in latest alias (#408) by @heitorlessa
- docs(tracer): Fix line highlighting (#395) by @michaelbrewer
🐛 Bug and hot fixes
- fix(parser): Improve types for parser.py (#419) by @carlos-alberto
- fix(validator): event type annotation as any in validate fn (#405) by @heitorlessa
Internal
- chore: bump to 1.15.0 (#422) by @heitorlessa
- fix(deps): Bump aws-xray-sdk from 2.6.0 to 2.8.0 (#413) by @michaelbrewer
This release was made possible by the following contributors:
@carlos-alberto, @heitorlessa, @michaelbrewer and @risenberg-cyberark
v1.14.0
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.
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 :)
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
- feat(parameter): add dynamodb_endpoint_url for local_testing (#376) by @rtrive
- fix(data-classes): Add missing operationName (#373) by @michaelbrewer
- fix(tracer): Correct type hint for MyPy (#365) by @michaelbrewer
📜 Documentation updates
- docs(logger): add example on how to set UTC timestamp (#392) by @heitorlessa
- docs(idempotency): add default table configuration for those not using IaC (#391) by @heitorlessa
- docs: Correct link targets and line highlights (#390) by @michaelbrewer
- docs(validator): include more complete examples & intro to JSON Schema (#389) by @heitorlessa
- docs: introduce event handlers utility section (#388) by @heitorlessa
- docs: Fix doc links and line highlights (#380) by @michaelbrewer
- docs: enable versioning feature (#374) by @heitorlessa
🐛 Bug and hot fixes
- fix: lock X-Ray SDK to 2.6.0 due to regression (#384) by @heitorlessa
- fix(idempotent): Correctly raise IdempotencyKeyError (#378) by @michaelbrewer
- fix(parser): S3Model support empty keys (#375) by @heitorlessa
- fix(metrics): AttributeError raised by MetricManager and Typing and docs (#357) by @michaelbrewer
🔧 Internal
- fix: downgrade poetry to 1.1.4 (#385) by @heitorlessa
- build(pre-commit): Add pre-commit to
make pr
(#368) by @michaelbrewer
This release was made possible by the following contributors:
@heitorlessa, @michaelbrewer, @risenberg-cyberark and @rtrive
Discussion: #394
v1.13.0
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.
Changes
🌟New features and non-breaking changes
- feat(data-classes): Add S3 Object Lambda Event (#353) by @michaelbrewer
📜 Documentation updates
- docs: Fix layers example template config (#350) by @BrockReece
🔧 Internal
- fix(deps): Bump dependencies and fix some of the dev tooling (#354) by @michaelbrewer
- fix(lint): Move
tests/THIRD-PARTY-LICENSES
to root (#352) by @michaelbrewer
This release was made possible by the following contributors:
v1.12.0
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
.
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!
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.
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
- feat(parameters): Add force_fetch option (#341) by @michaelbrewer
- feat(data-classes): Add appsync scalar_types_utils and add support for timezone offsets (#339) by @michaelbrewer
- feat(idempotent): Include function name in the idempotent key (#326) by @michaelbrewer
- feat(data-classes): AppSync Resolver Event (#323) by @michaelbrewer
- feat(logging): Add correlation_id support (#321) by @michaelbrewer
- feat(logging): Include exception_name (#320) by @michaelbrewer
📜 Documentation updates
- docs: surface new 1.12.0 features and enhancements (#344) by @heitorlessa
- docs(data-classes): Add more cognito code examples (#340) by @michaelbrewer
- docs: Correct code examples (#317) by @michaelbrewer
- docs(metrics): Correct code examples in markdown (#316) by @michaelbrewer
- docs(metrics): Corrections to the docstrings code examples (#314) by @michaelbrewer
- docs(idempotency): Correct examples and line highlights (#312) by @michaelbrewer
🐛 Bug and hot fixes
- docs(tracer): Fix Tracer typing hinting for Pycharm (#345) by @michaelbrewer
- fix(idempotency): TypeError when calling is_missing_idempotency_key with an int (#315) by @michaelbrewer
- fix(idempotency): Correctly handle save_inprogress errors (#313) by @michaelbrewer
Internal
- refactor(parameters): Consistently reference env (#319) by @michaelbrewer
This release was made possible by the following contributors:
v1.11.0
Changes
This is our most special release this quarter, as we are happy to announce:
- Up to 75% performance improvement for customers not using Tracer utility due to lazy loading
- Up to 40% performance improvement for customers using Metrics as large operations are now <1ms
- 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
Warm execution logging, serializing, and validating 99 Metrics to CloudWatch asynchronously on the lowest Lambda fn memory (128) after all optimizations
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 :-)
🌟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
- docs(dataclasses): new Connect Contact Flow (#310) by @heitorlessa
- docs(idempotency): tidy up doc before release (#309) by @heitorlessa
- docs(batch): add example on how to integrate with sentry.io (#308) by @heitorlessa
- docs(idempotent): Fix typos and code formatting (#305) by @michaelbrewer
- docs(data-classes): Correct import for DynamoDBRecordEventName (#299) by @michaelbrewer
🐛 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
v1.10.4
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
- docs(data-classes): Fix anchor tags to be lower case (#288) by @michaelbrewer
- chore: Correct the docs location for the labeller (#289) by @michaelbrewer
Internal
- chore: version bump to 1.10.4 (#291) by @cakepietoast
This release was made possible by the following contributors:
@cakepietoast, @heitorlessa and @michaelbrewer