aws / aws/amazon-redshift-python-driver

IAMR not supported

未关闭
#255 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
220
派生
86
PR 合并指标
30 天内没有已合并 PR

描述

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'}
```

贡献指南

打开贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
aws, python
领域
authentication, databases
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。