Reputation: 671
I just want to connect to the data stored in my Redshift serverless using Python.
I see an error when I run the code below.
import redshift_connector
conn = redshift_connector.connect(
host='Endpoint in the screenshot',
database='dev',
user='my aws account id',
password='my aws pw',
)
Since it is serverless, the 'Endpoint in the screenshot' looks like '111111111111.us-east-1.redshift-serverless.amazonaws.com' (the red box in the image below).
The error says "redshift_connector.error.InterfaceError: ('communication error', TimeoutError(60, 'Operation timed out'))" When I searched about it, some mentioned 'Edit inbound rules' in Security Group. So I added one rule there with a protocol TCP. Also, some people mentioned 'making the cluster public'. I am not sure if I can set this for the Redshift Serverless. I cannot find the webpage. Plus, some instructions with Redshift require 'cluster_id' as an argument, and I cannot find this info.
What else can I try?
FYI. I am not familiar with AWS. I installed AWS CLI, and I could get the data using CLI by running "aws redshift-data execute-statement ...". So I think it is also possible to get the data using Python libraries. Right?
Upvotes: 1
Views: 5248
Reputation: 1
Remember to create a Lambda layer containing the redshift-connector library and then add it to the Lambda function. A common mistake with Lambda is assuming that including an import statement is always enough. And even after creating a new layer, it is common to forget to then explicitly attach that new layer to the function.
Upvotes: 0
Reputation: 4267
You can make your serverless cluster publicly accessible: https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-connecting.html
There is a setting when you create the workgroup to make publicly accessible this means it will be able to be queried from the internet.
Otherwise you have to query it from a lambda function or EC2 instance in the same VPC that your cluster is in, which is a better security setting as all the traffic stays in the VPC.
Upvotes: 2