powertools-lambda-python: Bug: v2.16.1 [ERROR] Runtime.ImportModuleError: Unable to import module 'src.generate_token': aws-lambda-powertools Traceback (most recent call last):
Expected Behaviour
Expected our lambdas to run normally with the new version of aws-lambda-powertools
Current Behaviour
We get errors on importing aws-lambda-powertools with v2.16.1, but v2.15.0 works fine.
We experienced errors on all of our lambdas that use aws-lambda-powertools with 2.16.1. We import ‘aws_lambda_powertools’ in a requirements.txt file in a layer.
Then we attach that layer to a lambda. The lambda calls import like this ‘’’ from aws_lambda_powertools import Logger ‘’’
This is where we get the failure: ‘’’ [ERROR] Runtime.ImportModuleError: Unable to import module ‘src.generate_token’: aws-lambda-powertools Traceback (most recent call last): ‘’’
There is no other information, and it is really difficult to tell why it is failing. But pinning the requirements.txt file to 2.15.0 fixed everything.
Code snippet
'''
from aws_lambda_powertools import Logger
'''
Possible Solution
Roll back to 2.15.0
Steps to Reproduce
- Create a requirements.txt file with aws_lambda_powertools (note: we use underscores here but have seen it different in different places. We did try with dashes, but experienced failure)
- Create a Lambda Layer with the requirements.txt file
- Create a Lambda that uses the Layer
- Import aws_lambda_powertools Logger (from aws_lambda_powertools import Logger)
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.9
Packaging format used
Lambda Layers
Debugging logs
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 17 (13 by maintainers)
We were indeed using serverless too. I was able to test successfully with the new release 😃 Thanks so much for fixing this so quickly!! Much appreciated.
That seems to have fixed my issue
release completed: PyPi (2.16.2), Layer (34). Latest docs might take a few minutes for CDN to invalidate etc.
@bronzeson @CJTurpie @dionearle - would you mind triple checking with your build please?
I’ve tested with the latest Serverless framework and python-requirements plugin but want to be sure before we close it.
Thank you!
Got a solution that is safe to use in prod. Testing one more time before we merge and kick off a patch release.