简体   繁体   中英

AWS Lambda for Secrets Manager Password Rotation giving Errors for RDS(postgres)

I have downloaded the python function from https://github.com/aws-samples/aws-secrets-manager-rotation-lambdas/blob/master/SecretsManagerRDSPostgreSQLRotationSingleUser/lambda_function.py . Also, I am using Terraform to deploy ( Python Runtime is 3.9 as suggested). However, After deployment I am getting the following errors in CloudWatch Logs

[ERROR] Runtime.ImportModuleError: Unable to import module 'function': No module named 'pg' Traceback (most recent call last):

I also tried to create a Lambda layer but it did not help.

Appreciate any help !!

That Lambda function is apparently dependent on the PyGreSQL library . I don't see anything in the documentation for that function about that, but that's obviously what it is using. I'm surprised those sample functions don't include a requirments.txt file for their dependencies. There are some open issues in that GitHub repository related to this.

You would have to package that function's code along with the PyGreSQL library and any other dependencies into a.zip file, and modify your Terraform code to deploy the.zip file to Lambda.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM