aws / aws/amazon-redshift-python-driver

IAMR not supported

Open
#255 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
220
Forks
86
PR merge metrics
No merged PRs in 30d

Description

I can't connect to an IAMR redshift user with this lib

```sql
CREATE USER "IAMR:test_to_delete_redshift_ci" PASSWORD DISABLE;
```

but It work when I manually use boto3+psycopg2

```python

import os

import boto3
import psycopg2
import redshift_connector

os.environ["AWS_PROFILE"] = "redshift_test_role_2"

def with_lib():
conn = redshift_connector.connect(
iam=True,
cluster_identifier="YYYYYY",
database="AAAAA",
db_user="test_to_delete_redshift_ci",
password="",
region="eu-west-1",
)
cursor = conn.cursor()
cursor.execute("SELECT 10,20")
print(cursor.fetchall())

def manually():

RS_PORT = 5439
DATABASE = 'AAAAAA'
CLUSTER_ID = 'YYYYYYY'
RS_HOST = 'XXXXXXXXXXX'

client = boto3.client('redshift')

cluster_creds = client.get_cluster_credentials_with_iam(ClusterIdentifier=CLUSTER_ID)

print(cluster_creds)
conn = psycopg2.connect(
host=RS_HOST,
port=RS_PORT,
user=cluster_creds['DbUser'],
password=cluster_creds['DbPassword'],
database=DATABASE
)
cur = conn.cursor()
cur.execute("SELECT 10,20")

print(cur.fetchall())

if __name__ == '__main__':

with_lib()
manually()
```

with_lib fail with

```log
redshift_connector.error.ProgrammingError: {'S': 'FATAL', 'C': '42704', 'M': 'user "IAM:test_to_delete_redshift_ci" does not exist', 'F': '/opt/brazil-pkg-cache/packages/RedshiftPADB/RedshiftPADB-1.0.7910.0/AL2_x86_64/generic-flavor/src/src/pg/src/backend/utils/init/miscinit.c', 'L': '976', 'R': 'InitializeSessionUserId'}
```

Contributor guide

Open the contributing guide

Research direction

Start by running with_lib() and manually() from the issue example and compare the generated user and connection behavior. Trace the connector's IAM authentication entry point, then verify that an IAMR user connects successfully and that SELECT 10,20 returns the expected rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
authentication, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.