Registry / aws / aws-lambda-powertools

aws-lambda-powertools

JSON →
library3.34.0pypypi✓ verified 25d ago

Powertools for AWS Lambda (Python) is a developer toolkit designed to implement Serverless best practices and increase developer velocity. It offers utilities for tracing, logging, metrics, event handling, data parsing, and idempotency. The library is currently at version 3.27.0 and maintains an active development cycle with frequent releases, often shipping new features and bug fixes on a monthly basis.

pip install aws-lambda-powertools
INSTALL
IMPORT
SIG · AWS-LAMBDA-POWERTO
A
aws-lambda-powertools
awspythonv3.34.0
Install
2.0s avg
Import
107ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.34.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.114s · 24.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.100s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Logger
from aws_lambda_powertools import Logger
Tracer
from aws_lambda_powertools import Tracer
Metrics
from aws_lambda_powertools import Metrics
App
from aws_lambda_powertools.event_handler import App
from aws_lambda_powertools import App
The 'App' class for Event Handler is a sub-utility and must be imported from `aws_lambda_powertools.event_handler`.
Parser
from aws_lambda_powertools.utilities.parser import Parser
Idempotency
from aws_lambda_powertools.utilities.idempotency import IdempotencyConfig, idempotent

This quickstart demonstrates the `Logger` utility, automatically enriching logs with Lambda context and logging the incoming event. It's designed to run in an AWS Lambda environment.

import json from aws_lambda_powertools import Logger logger = Logger(service="payment_processing") @logger.inject_lambda_context(log_event=True) def handler(event, context): # Accessing event data via a common pattern if event and 'body' in event: try: body = json.loads(event['body']) transaction_id = body.get('transaction_id', 'N/A') logger.info(f"Processing transaction: {transaction_id}") except json.JSONDecodeError: logger.error("Invalid JSON in event body") return {"statusCode": 400, "body": json.dumps({"message": "Invalid JSON"})} else: logger.info("No event body provided.") logger.info("Hello from Lambda, using Powertools Logger!") return { "statusCode": 200, "body": json.dumps("Successfully processed request."), }
Debug
Known issues
breakingAWS Lambda Powertools v3.24.0 and later have dropped support for Python 3.9. Attempting to use these versions with a Python 3.9 runtime will result in errors.
fix
Upgrade your AWS Lambda function's runtime to Python 3.10 or newer. Python 3.14 is also supported from v3.23.0 onwards.
affects: >=3.24.0
gotchaVersions prior to v3.19.0 of AWS Lambda Powertools had critical bugs affecting Data validation and Middleware within the Event Handler utility, potentially leading to incorrect processing or validation errors.
fix
Upgrade to v3.19.0 or a later version to ensure correct behavior of Event Handler's data validation and middleware functionalities.
affects: <3.19.0
gotchaA regression was introduced in v3.22.0 affecting the Event Handler utility when using nested metadata annotations (e.g., `annotated_types` or `Interval`).
fix
If you are using Event Handler with nested metadata annotations, upgrade to v3.22.1 or a later version to resolve this regression.
affects: 3.22.0
gotchaAWS Lambda Powertools v3 is compatible with Pydantic V2. Users migrating from Pydantic V1 might need to update their model syntax (e.g., `model_validator` instead of `validator`) when using models with Event Handler or Parser utilities.
fix
Consult the Pydantic V2 migration guide and update your Pydantic models to adhere to the V2 syntax for seamless integration with Powertools.
affects: >=3.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aws_lambda_powertools'
The 'aws_lambda_powertools' module is not included in the Lambda deployment package.
fix
Ensure 'aws-lambda-powertools' is installed and included in your deployment package. If using AWS SAM, add it to your 'requirements.txt' and include it in the build process.
ImportError: /lib64/libc.so.6: version GLIBC_2.XX not found
The Lambda function is using a compiled extension that requires a different version of the GNU C Library (GLIBC) than what is available in the Lambda runtime.
fix
Use Docker with the appropriate Lambda base image to build your dependencies, ensuring compatibility with the Lambda runtime environment.
RequestEntityTooLargeException
The Lambda deployment package exceeds the maximum allowed size.
fix
Optimize your deployment package by using Lambda Layers for large dependencies, removing unnecessary files, and considering the use of container images for very large packages.
ImportError: cannot import name 'Logger' from 'aws_lambda_powertools'
The 'Logger' class is not found in the 'aws_lambda_powertools' module, possibly due to an incorrect import statement or version mismatch.
fix
Ensure you are using the correct import statement: 'from aws_lambda_powertools import Logger'. Also, verify that you have the latest version of 'aws-lambda-powertools' installed.
AttributeError: module 'aws_lambda_powertools' has no attribute 'Tracer'
The 'Tracer' attribute is not found in the 'aws_lambda_powertools' module, likely due to an incorrect import statement or version mismatch.
fix
Ensure you are using the correct import statement: 'from aws_lambda_powertools import Tracer'. Also, verify that you have the latest version of 'aws-lambda-powertools' installed.
Upgrade
Version history
3.34.0latest on PyPI · released Aug 10, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.10 or newer.
Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources
aws-lambda-powertools — pip install aws-lambda-powertools · libregistry