IAM authentication token does not work in Postgres connection string #1538
Unanswered
ejmolinelli
asked this question in
Questions
Replies: 2 comments
-
I can confirm this issue still exists |
Beta Was this translation helpful? Give feedback.
0 replies
-
You need to escape the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
The above code results in a runtime error:
However, the URL is correct. I can login in from the same environment using the
psql
command.Wanted Solution
The above code should run as is.
I did however come up with a solution which I posted here on stackoverflow.
The solution is to use the 'creator' argument to the
create_engine
function which returns a raw psycopg2 connection. (see alternatives below)Wanted Code
Alternatives
The following code works as a workaround
Operating System
Linux
Operating System Details
ubuntu EC2 image
SQLModel Version
0.0.6
Python Version
3.9
Additional Context
It can be a lot of setup to recreate this problem as it has to run in an AWS VPC (and I'd be happy to help ). Roughly the steps are
1 - Create a VPC
2 -Security Group 1 - Accept TCP traffic on port 5432 from Security Group 2
3 - Security Group 2 - Accept all incoming traffic and allow outgoing TCP traffic on port 5432
4 - RDS postgres instance and attach to security group 1 (same vpc and all subnets)
4a - add a new role with login and password (in addition to the master username and password)
5 - save master and new user username/password in secrets manager
6 - Create RDS proxy and attach Security Group 2 (same vpc and all subnets)
6a - proxy needs a role with policy to get secrets and decrypt secret
7 - Create an ec2 instance (same vpc)
7a - ec2 needs a role with policy to connect to rds-proxy and for both users (i.e. master user and new user)
7b - pip install psycopg2-binary
7c - pip install sqlmodel boto3
7d - run example code from python terminal on this instance
Beta Was this translation helpful? Give feedback.
All reactions