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