aws-secrets-manager-rotation-lambdas icon indicating copy to clipboard operation
aws-secrets-manager-rotation-lambdas copied to clipboard

Use psycopg2 for PostgreSQL DB operations

Open ryancausey opened this issue 5 years ago • 4 comments

Issue #, if available: Partially related to #24.

Description of changes: Updated the PostgreSQL rotation functions to use psycopg2. I've confirmed using this that I can successfully rotate credentials for the single user rotation use case in the AWS Lambda Python 3.7 runtime.

This was mainly motivated by issues I encountered trying to get pg and pgdb packaged properly for Lambda. Since I am using Terraform to deploy the secret and its rotation function I cannot rely on the serverless application repository version usually deployed via the console. This has the nice side effect of making the deployment package much smaller, since for some reason pip installing pg or pgdb installs a bunch of OpenGL stuff.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ryancausey avatar Nov 18 '19 03:11 ryancausey

@ryancausey

I ran into weirdness too, pg & pgdb are coming from pygresql. It's probably better to move to psycopg2 in any case.

However my blocker is on getting libpq.so.5 into the serverless machine, how are you getting that to work?

siassaj avatar Mar 10 '20 04:03 siassaj

@siassaj I used pip install psycopg2-binary to work around this. See: https://www.psycopg.org/docs/install.html#binary-install-from-pypi

I haven't personally run into issues the docs mention with the binary install, but your mileage may vary.

ryancausey avatar Mar 10 '20 04:03 ryancausey

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

joebaro avatar May 06 '21 17:05 joebaro

@joebaro I've rebased this onto the most recent version of master as of the time of writing this. Let me know if there are any issues to resolve. Thanks.

ryancausey avatar Sep 30 '21 02:09 ryancausey

Thank you for the pull request. Unfortunately we have no plans at this time to migrate to psycopg2.

jbct avatar Jun 05 '23 18:06 jbct