I have been trying to figure out how to connect to Amazon Redshift clusters when they are private rather than publicly accessible. I am trying to securely move data from our current MySQL DB to a cluster in Redshift. Currently I have a Python script which creates a CSV of the data, puts it in S3, creates a table for the data, then uses COPY to put it in Redshift. We are using the Python script to automate the process.
However I am completely unable to establish connections with Redhsift when the cluster is set to private. I did some digging and found out about SSH Tunneling as a potential solution. While Redshift doesn't support SSH to my knowledge it is possible to use a bastion host to connect using an ec2 instance running psql. The issue with this is I need to perform this in the Python script in order to keep the process as automated as possible.
I have created an ec2 instance and used PuTTY to load psql to it, however I am unsure of how to use that instance as a bastion host i.e. connecting to it and using it to connect to Redshift, and how to acually perform this in the python script if it is at all possible. Has anyone done anything similar or know how to connect to ec2 and from ec2 to redshift?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…