Skip to content

IAMR not supported #255

Open
Open
@raphaelauv

Description

@raphaelauv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions