Releases: aws-powertools/powertools-lambda-python
v1.25.6
Summary
This patch release fixes a regression in Logger introduced in 1.25.3 when using clear_state=True. A fix for customer formatters introduced in 1.25.3 ended up introducing a regression, where standard keys like level, location and timestamp no longer being present when using clear_state=True for the default Logger formatter.
Thanks to @alexanderluiscampino for a high quality bug report, and @HAK-CODE for confirming the issue two hours ago, we managed to reproduce it quickly, improved our tests, and thus making this emergency release.
Changes
🐛 Bug and hot fixes
- fix(logger): clear_state regression on absent standard keys (#1088) by @heitorlessa
This release was made possible by the following contributors:
@heitorlessa and @mergify[bot]
v1.25.5
Summary
Thanks to @DandyDev, this emergency release fixes a regression on logger utils to clone formatting configuration from Powertools Logger to external Loggers.
Changes
🐛 Bug and hot fixes
This release was made possible by the following contributors:
@heitorlessa, @mergify[bot] and @mploski
v1.25.4
Summary
This is a patch release for those using Logger utils to clone Lambda Powertools Logger configuration to all existing Python Loggers.
Thanks to @DandyDev for spotting a log duplication for external loggers, and for @mploski for helping fix it.
Changes
🐛 Bug and hot fixes
- fix(logger-utils): ensure external loggers doesn't propagate logs on config copy (#1075) by @mploski
This release was made possible by the following contributors:
@heitorlessa, @mploski and Michal Ploski
1.25.3
Summary
This patch release is strictly about customers bringing their own Logging Formatter.
This release ensures that when using Clear State with a custom formatter, all previously added keys will be cleared. It also guarantees that Lambda Context information will no longer be cleared abruptly before logs are printed (also for custom formatters).
There is no code change needed on customers end. We also improved the documentation to clarify the most common use cases on bringing your own formatter, and exceptional cases where you want to replace the entire Powertools Logger Formatter logic.
Huge thanks to @jacobdarrossi for spotting, and @ilias-at-adarma for confirming this bug.
Changes
📜 Documentation updates
- fix(logger): ensure state is cleared for custom formatters (#1072) by @heitorlessa
- docs(plugin): add mermaid to create diagram as code (#1070) by @dreamorosi
🐛 Bug and hot fixes
- fix(logger): ensure state is cleared for custom formatters (#1072) by @heitorlessa
This release was made possible by the following contributors:
v1.25.2
Summary
This patch release addresses two main bugs: 1/ API Gateway Lambda Authorizer data class regex to validate for proxy resources (proxy+), and 2/ metrics to be automatically flushed when a single metric has 100 values.
Next release will focus on two newly identified bugs on Logger (custom formatter, child logger). Subsequently, our bandwidth remains focused on addressing the subpar experiences and operational excellence.
Changes
📜 Documentation updates
- docs(parser): APIGatewayProxyEvent to APIGatewayProxyEventModel (#1061) by @darnley
- fix(event_handler): docs snippets, high-level import CorsConfig (#1019) by @michaelbrewer
🐛 Bug and hot fixes
- fix(metrics): flush upon a single metric 100th data point (#1046) by @knightjoel
- fix(lambda-authorizer): allow proxy resources path in arn (#1051) by @michaelbrewer
- fix(event_handler): docs snippets, high-level import CorsConfig (#1019) by @michaelbrewer
🔧 Maintenance
- chore(deps-dev): bump mkdocs-material from 8.1.9 to 8.2.4 (#1054) by @dependabot
- chore(deps): bump actions/setup-python from 2.3.1 to 3 (#1048) by @dependabot
- chore(deps): bump actions/checkout from 2 to 3 (#1052) by @dependabot
- chore(deps): bump actions/github-script from 5 to 6 (#1023) by @dependabot
- chore(deps): bump fastjsonschema from 2.15.2 to 2.15.3 (#949) by @dependabot
This release was made possible by the following contributors:
@darnley, @dependabot, @dependabot[bot], @heitorlessa, @knightjoel and @michaelbrewer
v1.25.1
Summary
Emergency release to fix a critical bug in the new BatchProcessor feature spotted by Huon Wilson@huonw, and thanks to @michaelbrewer for the quick fix. The issue was exceptions not being consistently cleared between invocations (cold vs warm state).
Changes
🐛 Bug and hot fixes
- fix(batch): bugfix to clear exceptions between executions (#1022) by @michaelbrewer
This release was made possible by the following contributors:
@heitorlessa, @mergify[bot] and @michaelbrewer
v1.25.0
Summary
This release continues to focus on addressing suboptimal experiences (a.k.a papercuts).
But first... big thanks to our first time contributors @am1ru1, @houbie - thank you for helping us improve everyone's experience!
Major improvements you should know
- Fully mypy compliant. After a multi-month task addressing over 600 issues, Mypy users can accurately use all 14 utilities typing annotations - thanks @mploski for getting us to the finishing line!
- New specialized Event Handler Resolvers. When using
ApiGatewayResolverto access event properties, customers didn't have full IntelliSense support from their IDEs. This release introducesAPIGatewayRestResolver,APIGatewayHttpResolver, andALBResolverto accurately provide self-documented access to all properties available - big thanks to @michaelbrewer. - Testing your code docs. We've updated Parameters & Event Handler GraphQL docs to be more realistic on how you can unit test your code - thanks to @cakepietoast
Roadmap changes
We're going to fully turn our attention to our list of papercuts. Due to new features and other bugs, we let it slip a couple of times, one being as old as ~7 months. We also learned that a central roadmap didn't work well for us. It made planning harder due to the split view (2x repos to look at) situation despite its best intentions.
With GitHub's new Beta projects, we're confident we can migrate the roadmap back to each repository and give the visibility customers have been asking us. That is work we're currently doing, themes that need further research, areas we'd love contributions, and ideas we'd love to execute but lack bandwidth.
Once this is complete, we will start a draft RFC of what a modularized Powertools v2 could look like. We will take everyone's input as much as possible to help shape what breaking changes are necessary, how we might facilitate new utilities like Testing, and what an early beta as well as migration guide should look like.
Changes
🌟New features and non-breaking changes
- feat(event-handler): new resolvers to fix current_event typing (#978) by @michaelbrewer
- feat(logger): log_event support event data classes (e.g. S3Event) (#984) by @michaelbrewer
- feat(mypy): complete mypy support for the entire codebase (#943) by @mploski
📜 Documentation updates
- docs: fix syntax errors and line highlights (#1004) by @michaelbrewer
- docs(parameters): add testing your code section (#1017) by @cakepietoast
- docs(theme): upgrade mkdocs-material to 8.x (#1002) by @heitorlessa
- docs(event-handler): improve testing section for graphql (#996) by @cakepietoast
- docs(tutorial): fix broken internal links (#1000) by @heitorlessa
- feat(event-handler): new resolvers to fix current_event typing (#978) by @michaelbrewer
- fix(docs): indentation in tutorial snippets (#988) by @am1ru1
- fix(apigateway): remove indentation in debug_mode (#987) by @heitorlessa
🐛 Bug and hot fixes
- fix(batch): delete >10 messages in legacy sqs processor (#818) by @whardier
- fix(logger): exclude source_logger in copy_config_to_registered_loggers (#1001) by @houbie
- feat(event-handler): new resolvers to fix current_event typing (#978) by @michaelbrewer
- fix(logger): test generates logfile (#971) by @michaelbrewer
- fix(docs): indentation in tutorial snippets (#988) by @am1ru1
- fix(apigateway): remove indentation in debug_mode (#987) by @heitorlessa
🔧 Maintenance
- chore(metrics): fix tests when warnings are disabled (#994) by @michaelbrewer
- docs(theme): upgrade mkdocs-material to 8.x (#1002) by @heitorlessa
- feat(mypy): complete mypy support for the entire codebase (#943) by @mploski
- chore(deps-dev): bump flake8-bugbear from 21.11.29 to 22.1.11 (#955) by @dependabot
This release was made possible by the following contributors:
@am1ru1, @cakepietoast, @dependabot, @dependabot[bot], @heitorlessa, @houbie, @mergify[bot], @michaelbrewer, @mploski and @whardier
v1.24.2
Summary
Quick patch release to fix an issue with API Gateway Authorizer in Event Source Data Classes not supporting resource names using _. It's an old bug in the original blueprint this code was based on. However, it prevents anyone from having a _ in the resource name get_something which is significant enough to warrant a patch release for that alone.
Thanks to Chris Elkin for raising and @michaelbrewer for the quick fix (as always).
Changes
🐛 Bug and hot fixes
- fix(data-classes): underscore support in api gateway authorizer resource name (#969) by @michaelbrewer
This release was made possible by the following contributors:
@heitorlessa, @mergify[bot] and @michaelbrewer
v1.24.1
Summary
This is an emergency release to fix a critical Batch bug spotted by @kimberlyamandalu, where multiple failed records weren't reported due to dictionary key uniqueness - If you are using BatchProcessor, please update to 1.24.1 as soon as possible.
New official tutorial
Thanks to the gigantic effort by @mploski and @am29d on reviewing it, we now finally have an official tutorial covering core Powertools features. The tutorial demonstrates how new customers can add one feature at a time. It also opens the door to create other tutorials covering other complex features in more depth.
Please do let us know your thoughts and what other tutorials we should focus on next ;-)
New tiny function to copy Logger config to external loggers
A common question we receive is: How can I enable powertools logging for imported libraries?
Thanks to @mploski, we now have a tiny standalone function you can use to copy your current Logger config to any or a select list of loggers you want.
Why would people want that? It's a fair question. Reason is sometimes you want external libraries to have the exact same structured logging that your application has. This function allows you to specify which explicit loggers you wanna copy config to (or all), and whether you want to set a different log level.
import logging
from aws_lambda_powertools import Logger
from aws_lambda_powertools.logging import utils
logger = Logger()
external_logger = logging.logger()
utils.copy_config_to_registered_loggers(source_logger=logger)
external_logger.info("test message")Big thanks to new contributors @thehananbhat @j2clerck on helping us make documentation better (critical to us!).
Changes
🌟New features and non-breaking changes
🌟 Minor Changes
- fix(data-classes): docstring typos and clean up (#937) by @michaelbrewer
📜 Documentation updates
- docs(tutorial): fix path to images (#963) by @mploski
- docs(batch): snippet typo in custom batch processor (#961) by @thehananbhat
- docs(batch): snippet typo on batch processed messages iteration (#951) by @j2clerck
- docs(nav): make REST and GraphQL event handlers more explicit (#959) by @heitorlessa
- docs(logger): fix code block syntax in FAQ (#952) by @mozz100
- docs(tutorial): add new tutorial covering core features (#769) by @mploski
- docs(homepage): link to typescript version (#950) by @michaelbrewer
- fix(parameters): appconfig internal _get docstrings (#934) by @ran-isenberg
- docs(batch): fix typo in context manager keyword (#938) by @heitorlessa
- feat(logger): clone powertools logger config to any Python logger (#927) by @mploski
🐛 Bug and hot fixes
- fix(batch): report multiple failures (#967) by @heitorlessa
- fix(parameters): appconfig internal _get docstrings (#934) by @ran-isenberg
🔧 Maintenance
- docs(tutorial): fix path to images (#963) by @mploski
- chore(deps): bump pydantic from 1.8.2 to 1.9.0 (#933) by @dependabot
- chore(deps-dev): bump mypy from 0.930 to 0.931 (#941) by @dependabot
This release was made possible by the following contributors:
@dependabot, @dependabot[bot], @heitorlessa, @j2clerck, @michaelbrewer, @mozz100, @mploski, @ran-isenberg, @thehananbhat and Michal Ploski
v1.24.0
Summary
For the last release of the year (happy 2022!), we bring a major enhancements to Idempotency and Feature Flags.
We also addresses important papercuts like caching parsed JSON data in Event Sources, support for datetime format codes in Logger and the ability to ignore certain endpoints from being traced.
Did I say that 90% of this release was contributed by the community? thank you everyone!!!
HUGE shoutout to @DanyC97 on helping us make all of our documentation banners (warning, tip) consistent.
Big thanks to new contributors too (you rock!)
- @trey-rosius for adding a medium-size GraphQL API example using a myriad of Lambda Powertools features
- @nayaverdier for a future proof change on how we internally convert string to bool (distutils being deprecated in Python 3.12)
idempotent_function now supports dataclasses & Pydantic models
When using idempotent_function to make any Python synchronous function idempotent, you might have data available as Dataclasses or Pydantic models, not just dictionaries.
This release gives you more flexibility on what data can be used as your idempotency token - it could be an entire Dataclass, Pydantic model, or fields within these models.
Going beyond boolean feature flags
You can now use the new boolean_feature: false parameter in your schema to signal Feature Flags that you will return any JSON valid value.
Example scenario: you might have a list of features to unlock for premium customers, or a set of beta features for select customers
{
"premium_features": {
"boolean_type": false,
"default": [],
"rules": {
"customer tier equals premium": {
"when_match": ["no_ads", "no_limits", "chat"],
"conditions": [
{
"action": "EQUALS",
"key": "tier",
"value": "premium"
}
]
}
}
}
}Translating to the following API:
from aws_lambda_powertools.utilities.feature_flags import FeatureFlags, AppConfigStore
app_config = AppConfigStore(
environment="dev",
application="product-catalogue",
name="features"
)
feature_flags = FeatureFlags(store=app_config)
def lambda_handler(event, context):
# Get customer's tier from incoming request
ctx = { "tier": event.get("tier", "standard") }
# Evaluate `has_premium_features` base don customer's tier
premium_features: list[str] = feature_flags.evaluate(name="premium_features",
context=ctx, default=False)
for feature in premium_features:
# enable premium features
...Ignoring HTTP endpoints from tracer
AWS X-Ray has a limit of 64K tracing data. This could be a problem if you're making hundreds of HTTP requests to the same endpoint.
Alternatively, there are sensitive endpoints you might want them to not be included in your tracing data.
You can now use ignore_endpoint for this purpose - globs (*) are allowed!
from aws_lambda_powertools import Tracer
tracer = Tracer()
# ignore all calls to `ec2.amazon.com`
tracer.ignore_endpoint(hostname="ec2.amazon.com")
# ignore calls to `*.sensitive.com/password` and `*.sensitive.com/credit-card`
tracer.ignore_endpoint(hostname="*.sensitive.com", urls=["/password", "/credit-card"])
def ec2_api_calls():
return "suppress_api_responses"
@tracer.capture_lambda_handler
def handler(event, context):
for x in long_list:
ec2_api_calls()Changes
🌟New features and non-breaking changes
- feat(logger): support use_datetime_directive for timestamps (#920) by @huonw
- feat(feature_flags): support beyond boolean values (JSON values) (#804) by @ran-isenberg
- feat(idempotency): support dataclasses & pydantic models payloads (#908) by @michaelbrewer
- feat(tracer): ignore tracing for certain hostname(s) or url(s) (#910) by @michaelbrewer
- feat(event-sources): cache parsed json in data class (#909) by @michaelbrewer
📜 Documentation updates
- docs(tracer): new ignore_endpoint feature (#931) by @heitorlessa
- feat(logger): support use_datetime_directive for timestamps (#920) by @huonw
- feat(feature_flags): support beyond boolean values (JSON values) (#804) by @ran-isenberg
- docs(general): consistency around admonitions and snippets (#919) by @DanyC97
- docs(homepage): new GraphQL sample API in examples section (#930) by @trey-rosius
- feat(idempotency): support dataclasses & pydantic models payloads (#908) by @michaelbrewer
🐛 Bug and hot fixes
- fix(event-sources): handle dynamodb null type as none, not bool (#929) by @michaelbrewer
- fix(apigateway): support @app.not_found() syntax & housekeeping (#926) by @michaelbrewer
🔧 Maintenance
- chore(deps-dev): bump mypy from 0.920 to 0.930 (#925) by @dependabot
- fix(apigateway): support @app.not_found() syntax & housekeeping (#926) by @michaelbrewer
- fix(internals): future distutils deprecation (#921) by @nayaverdier
This release was made possible by the following contributors:
@DanyC97, @dependabot, @dependabot[bot], @heitorlessa, @huonw, @michaelbrewer, @nayaverdier, @ran-isenberg and @trey-rosius
New Contributors
- @nayaverdier made their first contribution in #921
- @trey-rosius made their first contribution in #930
Full Changelog: v1.23.0...v1.23.1

