Skip to content

Bug: v2.16.1 [ERROR] Runtime.ImportModuleError: Unable to import module 'src.generate_token': aws-lambda-powertools Traceback (most recent call last): #2381

Closed
@bronzeson

Description

@bronzeson

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions