Giter Site home page Giter Site logo

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'pg' about aws-secrets-manager-rotation-lambdas HOT 9 CLOSED

hemantproTR avatar hemantproTR commented on June 8, 2024 10
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'pg'

from aws-secrets-manager-rotation-lambdas.

Comments (9)

veelenga avatar veelenga commented on June 8, 2024 1

@luchees this is doable if the lambda is a part of the cloudformation template, but in my case, it is a hosted one, meaning cloud formation creates a substack automatically when a rotation schedule is created. I don't have any control over the lambda dependencies.

However, my problem was solved by re-creating RotationSchedule. Not sure why it was broken.

from aws-secrets-manager-rotation-lambdas.

rstevens011 avatar rstevens011 commented on June 8, 2024 1

Hello everyone! Please review https://repost.aws/knowledge-center/secrets-manager-lambda-rotation. TLDR, if this is still impacting your lambda function, add the Runtime key to your AWS::SecretsManager::RotationSchedule resource (see docs here) with the version of python that the binary .so files are compiled against.

from aws-secrets-manager-rotation-lambdas.

whygoyal avatar whygoyal commented on June 8, 2024

Thank you for opening this issue - we are looking into it.

from aws-secrets-manager-rotation-lambdas.

babuknb avatar babuknb commented on June 8, 2024

Please let me know if any updates. Thanks.

from aws-secrets-manager-rotation-lambdas.

nomadme avatar nomadme commented on June 8, 2024

@whygoyal Any update on this?

from aws-secrets-manager-rotation-lambdas.

Monikaa7 avatar Monikaa7 commented on June 8, 2024

I had the same issue with pymysql, fixed it by installing the package and zipping it with the function itself. You can follow up the AWS documentation for this - https://docs.aws.amazon.com/lambda/latest/dg/python-package.html

from aws-secrets-manager-rotation-lambdas.

veelenga avatar veelenga commented on June 8, 2024

Is there anything required in order to fix this problem when lambda is deployed as part of RotationSchedule ?

RotationSchedule:
  Type: AWS::SecretsManager::RotationSchedule
  Properties:
    HostedRotationLambda:
      RotationLambdaName: DBSecretRotationScheduleLambda
      RotationType: PostgreSQLSingleUser
      # ...

Logged error message is basically the same:

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named '_pg'

from aws-secrets-manager-rotation-lambdas.

luchees avatar luchees commented on June 8, 2024

sudo apt-get install libpq-dev

add requirements.txt:

PyGreSQL == 5.0.7

pip3 install --target ./package -r requirements.txt

include the package directory with the lambda_function.py in a zip file use that as the lambda zip file

from aws-secrets-manager-rotation-lambdas.

nicholasgriffintn avatar nicholasgriffintn commented on June 8, 2024

Don't want to plus one this, but I've had this same issue today, on one AWS account, our function was working properly, for some reason, on the other, it was not.

Exporting from the working AWS account to the none working resolved it, but they were the same size before and after, so I'm not actually sure what that changed.

One of those creepy magic fixes....

To note: This occurred after a PG version update, but only on one of our AWS accounts, despite being updated in the same way, via CloudFormation.

from aws-secrets-manager-rotation-lambdas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.