Skip to content

Commit 1edd9ba

Browse files
committed
fix(connection, iam-auth): host, port connect() params override describe_cluster response
1 parent 2493edb commit 1edd9ba

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

redshift_connector/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def connect(
125125
database: str,
126126
password: str,
127127
port: int = 5439,
128-
host: str = "localhost",
128+
host: str = "",
129129
source_address: typing.Optional[str] = None,
130130
unix_sock: typing.Optional[str] = None,
131131
ssl: bool = True,

redshift_connector/iam_helper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,11 @@ def set_cluster_credentials(
377377
else:
378378
client = boto3.client(service_name="redshift", **session_credentials)
379379

380-
response = client.describe_clusters(ClusterIdentifier=info.cluster_identifier)
381-
info.host = response["Clusters"][0]["Endpoint"]["Address"]
382-
info.port = response["Clusters"][0]["Endpoint"]["Port"]
380+
if info.host is None or info.host == "" or info.port is None or info.port == "":
381+
response = client.describe_clusters(ClusterIdentifier=info.cluster_identifier)
382+
383+
info.host = response["Clusters"][0]["Endpoint"]["Address"]
384+
info.port = response["Clusters"][0]["Endpoint"]["Port"]
383385

384386
# temporary credentials are cached by redshift_connector and will be used if they have not expired
385387
cache_key: str = IamHelper.get_credentials_cache_key(info)

0 commit comments

Comments
 (0)