Skip to content

IAMR not supported #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
raphaelauv opened this issue Feb 26, 2025 · 0 comments
Open

IAMR not supported #255

raphaelauv opened this issue Feb 26, 2025 · 0 comments

Comments

@raphaelauv
Copy link

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

CREATE USER "IAMR:test_to_delete_redshift_ci" PASSWORD DISABLE;

but It work when I manually use boto3+psycopg2

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

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'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant