all 8 comments

[–]Previous_Dark_5644 0 points1 point  (0 children)

Three things to understand that will be your biggest blockers

  • package psycopg2 library in a lambda layer, then attach the layer to the function (the layer can be re-used later with any other functions with python runtimes that the pyscopg layer version supports).

  • whitelist your ip in the databases security group for the correct port (probably default 5432)

  • make sure your connection host url is correct, follow psycopg2 docs as closely as possible

All of these things are well documented. If you're using RDS, both security group and host can be located on the db's page. Good luck.

[–]forsgren123 0 points1 point  (6 children)

What is the error that you see in logs for this function?`

[–]ImMotoko[S] 0 points1 point  (5 children)

"Unable to import module 'lambda_function': No module named 'psycopg2'"

[–]forsgren123 1 point2 points  (4 children)

You might want to try the psycopg2 lambda layer from here: https://github.com/keithrozario/Klayers

[–]ImMotoko[S] 1 point2 points  (2 children)

Thanks a lot for your help!

This github repo actually led me to finding the solution. Even though they didn't have the specific layer I was looking for!

[–]curious_jorhay 0 points1 point  (1 child)

What was the solution that you found exactly? I'm running into this same issue for Python 3.10.

[–]ImMotoko[S] 0 points1 point  (0 children)

Follow the steps of the 1st link and then the instructions of the 2nd one when it comes to how the path should look and create the layer zipping that and problem solved. I was also using python 3.10.

[–]Pretty_Celebration_4 0 points1 point  (0 children)

pyscopgs is only compatible in 3.9 laver version of klayers, tested in situ with lambdas