Cannot connect to redshift using IAM credentials
See original GitHub issueDriver version
2.0.888
Redshift version
1.0.31802
Client Operating System
Mac os
Python version
3.8
Problem description
Unable to connect to redshift cluster using IAM role from my local machine using redshift-connector
package.
Connection is successful when using normal username & password to connect :
conn = redshift_connector.connect(
host=<my_redshift_host>,
database='dev',
user='redshift-admin',
password='iajsdoiajsdoijaosdijaojsd'
)
Error - raise InterfaceError("communication error", e) redshift_connector.error.InterfaceError: ('communication error', gaierror(8, 'nodename nor servname provided, or not known'))
Reproduction code
conn = redshift_connector.connect(
iam=True,
database='dev',
db_user='redshift-admin',
password='', # tried using aws user password
user='', # tried using aws username
cluster_identifier='redshift-cluster-1',
profile='default'
)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Configure a JDBC or ODBC connection to use IAM credentials
Under Authentication, choose a value for Auth Type. Enter the name of a profile in an AWS config file that contains values for...
Read more >Connect to Redshift using Python using IAM Role
It supports connecting using IAM, given your IAM credentials allows you to call get-cluster-credentials.
Read more >Options for providing IAM credentials - Amazon Redshift
To provide IAM credentials for a JDBC or ODBC connection, choose one of the following options. Amazon profile. As an alternative to providing...
Read more >Connecting to Amazon Redshift Using IAM Credentials via ...
When connecting to Redshift via JDBC and using IAM credentials as authentication, three fields are required: the AWS Access Key, the AWS Secret...
Read more >AWS Lambda to Redshift Connection using IAM ... - Mitoc Group
Securely storing and rotating Amazon Redshift's credentials was becoming another full time project;; IAM authentication for Amazon Redshift is ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
host
incore.py
was different from actual redshift host. Further investigation showed that region in my~/.aws/credentials
and~/.aws/config
was different from the region where redshift cluster exist. So I set those regions in my credentials and config file to match the redshift region and it worked.Thank you @aseem-poloniex ,
I’ve been unable to reproduce this failure locally. I took the following steps to setup using IAM from the default profile.
~/.aws/credentials
Also, you shouldn’t need to pass
user
orpassword
toredshift_connector.connect(...)
, assuming you don’t intend to pass and values.The contents of
~/.aws/credentials
Based on where this error is occurring, the IAM authentication has completed (i.e. hostname, port, and IAM user have been retrieved) and and the problem is with creating a connection to the hostname for cluster (which is returned during the authentication process), which makes me think this is an issue with the IAM role’s configuration or the DNS responder on your Mac. Usually when there is an issue with the IAM role, an error about connection timeout is populated, but I figure this would be good to double check.
I’d recommend trying the following:
core.py
where the exception is raised. Look to the variableshost
andport
. Are they as expected? What happens if you executetelent <host> <port>
?If you continue to see issue, please generate the debug logs using the instructions here and provide them in this issue so I can investigate further.