pythonamazon-web-servicesaws-lambdaaws-amplifypsycopg2

Using psycopg2 within AWS Lambda and AWS Amplify


Before someone marks this as a duplicate, I've reviewed No module named 'psycopg2._psycopg': ModuleNotFoundError in AWS Lambda

and attempted as best as I can the steps listed in this repo: https://github.com/jkehler/awslambda-psycopg2

I'm building a web application in AWS Amplify which packages the lambda itself so regardless of using his precompiled options or generating it myself from scratch, I am unsure where I would even put the folder. I tried several places but I keep getting the error:

Unable to import module 'index': No module named 'psycopg2._psycopg

I also tried a lambda layer from this repo with the same result: https://github.com/jetbridge/psycopg2-lambda-layer

So is there a specific place I should put the generated folder? Is there a lambda layer that works?


Solution

  • So instead of actually finding the answer to this question I built a lambda layer with the psycopg2 library provided in the first repo and uploaded it, then it worked!